Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(415)

Side by Side Diff: remoting/webapp/crd/js/error.js

Issue 837113003: Fix host delete. Delete always returns a 204 (empty response), which will throw an "authentication … (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Merge Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 'use strict'; 5 'use strict';
6 6
7 /** @suppress {duplicate} */ 7 /** @suppress {duplicate} */
8 var remoting = remoting || {}; 8 var remoting = remoting || {};
9 9
10 /** 10 /**
(...skipping 18 matching lines...) Expand all
29 UNEXPECTED: /*i18n-content*/'ERROR_UNEXPECTED', 29 UNEXPECTED: /*i18n-content*/'ERROR_UNEXPECTED',
30 SERVICE_UNAVAILABLE: /*i18n-content*/'ERROR_SERVICE_UNAVAILABLE', 30 SERVICE_UNAVAILABLE: /*i18n-content*/'ERROR_SERVICE_UNAVAILABLE',
31 NOT_AUTHENTICATED: /*i18n-content*/'ERROR_NOT_AUTHENTICATED', 31 NOT_AUTHENTICATED: /*i18n-content*/'ERROR_NOT_AUTHENTICATED',
32 INVALID_HOST_DOMAIN: /*i18n-content*/'ERROR_INVALID_HOST_DOMAIN', 32 INVALID_HOST_DOMAIN: /*i18n-content*/'ERROR_INVALID_HOST_DOMAIN',
33 P2P_FAILURE: /*i18n-content*/'ERROR_P2P_FAILURE', 33 P2P_FAILURE: /*i18n-content*/'ERROR_P2P_FAILURE',
34 REGISTRATION_FAILED: /*i18n-content*/'ERROR_HOST_REGISTRATION_FAILED', 34 REGISTRATION_FAILED: /*i18n-content*/'ERROR_HOST_REGISTRATION_FAILED',
35 NOT_AUTHORIZED: /*i18n-content*/'ERROR_NOT_AUTHORIZED' 35 NOT_AUTHORIZED: /*i18n-content*/'ERROR_NOT_AUTHORIZED'
36 }; 36 };
37 37
38 /** 38 /**
39 * @param {number} httpError An HTTP error code. 39 * @param {number} httpStatus An HTTP status code.
40 * @return {remoting.Error} The remoting.Error enum corresponding to the 40 * @return {remoting.Error} The remoting.Error enum corresponding to the
41 * specified HTTP error code. 41 * specified HTTP status code.
42 */ 42 */
43 remoting.Error.fromHttpError = function(httpError) { 43 remoting.Error.fromHttpStatus = function(httpStatus) {
44 if (httpError == 0) { 44 if (httpStatus == 0) {
45 return remoting.Error.NETWORK_FAILURE; 45 return remoting.Error.NETWORK_FAILURE;
46 } else if (httpError == 200) { 46 } else if (httpStatus >= 200 && httpStatus < 300) {
47 return remoting.Error.NONE; 47 return remoting.Error.NONE;
48 } else if (httpError == 400 || httpError == 401) { 48 } else if (httpStatus == 400 || httpStatus == 401) {
49 return remoting.Error.AUTHENTICATION_FAILED; 49 return remoting.Error.AUTHENTICATION_FAILED;
50 } else if (httpError >= 500 && httpError < 600) { 50 } else if (httpStatus >= 500 && httpStatus < 600) {
51 return remoting.Error.SERVICE_UNAVAILABLE; 51 return remoting.Error.SERVICE_UNAVAILABLE;
52 } else { 52 } else {
53 console.warn('Unexpected HTTP error code: ' + httpError); 53 console.warn('Unexpected HTTP error code: ' + httpStatus);
54 // Return AUTHENTICATION_FAILED by default, so that the user can try to 54 // Return AUTHENTICATION_FAILED by default, so that the user can try to
55 // recover from an unexpected failure by signing in again. 55 // recover from an unexpected failure by signing in again.
56 // TODO(jamiewalch): Return UNEXPECTED here and let calling code treat that 56 // TODO(jamiewalch): Return UNEXPECTED here and let calling code treat that
57 // as "sign-in required" if necessary. 57 // as "sign-in required" if necessary.
58 return remoting.Error.AUTHENTICATION_FAILED; 58 return remoting.Error.AUTHENTICATION_FAILED;
59 } 59 }
60 }; 60 };
OLDNEW
« no previous file with comments | « remoting/webapp/app_remoting/js/app_remoting.js ('k') | remoting/webapp/crd/js/host_list_api_impl.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698