Path: blob/trunk/third_party/closure/goog/net/errorcode.js
2868 views
// Copyright 2007 The Closure Library Authors. All Rights Reserved.1//2// Licensed under the Apache License, Version 2.0 (the "License");3// you may not use this file except in compliance with the License.4// You may obtain a copy of the License at5//6// http://www.apache.org/licenses/LICENSE-2.07//8// Unless required by applicable law or agreed to in writing, software9// distributed under the License is distributed on an "AS-IS" BASIS,10// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.11// See the License for the specific language governing permissions and12// limitations under the License.1314/**15* @fileoverview Error codes shared between goog.net.IframeIo and16* goog.net.XhrIo.17*/1819goog.provide('goog.net.ErrorCode');202122/**23* Error codes24* @enum {number}25*/26goog.net.ErrorCode = {2728/**29* There is no error condition.30*/31NO_ERROR: 0,3233/**34* The most common error from iframeio, unfortunately, is that the browser35* responded with an error page that is classed as a different domain. The36* situations, are when a browser error page is shown -- 404, access denied,37* DNS failure, connection reset etc.)38*39*/40ACCESS_DENIED: 1,4142/**43* Currently the only case where file not found will be caused is when the44* code is running on the local file system and a non-IE browser makes a45* request to a file that doesn't exist.46*/47FILE_NOT_FOUND: 2,4849/**50* If Firefox shows a browser error page, such as a connection reset by51* server or access denied, then it will fail silently without the error or52* load handlers firing.53*/54FF_SILENT_ERROR: 3,5556/**57* Custom error provided by the client through the error check hook.58*/59CUSTOM_ERROR: 4,6061/**62* Exception was thrown while processing the request.63*/64EXCEPTION: 5,6566/**67* The Http response returned a non-successful http status code.68*/69HTTP_ERROR: 6,7071/**72* The request was aborted.73*/74ABORT: 7,7576/**77* The request timed out.78*/79TIMEOUT: 8,8081/**82* The resource is not available offline.83*/84OFFLINE: 985};868788/**89* Returns a friendly error message for an error code. These messages are for90* debugging and are not localized.91* @param {goog.net.ErrorCode} errorCode An error code.92* @return {string} A message for debugging.93*/94goog.net.ErrorCode.getDebugMessage = function(errorCode) {95switch (errorCode) {96case goog.net.ErrorCode.NO_ERROR:97return 'No Error';9899case goog.net.ErrorCode.ACCESS_DENIED:100return 'Access denied to content document';101102case goog.net.ErrorCode.FILE_NOT_FOUND:103return 'File not found';104105case goog.net.ErrorCode.FF_SILENT_ERROR:106return 'Firefox silently errored';107108case goog.net.ErrorCode.CUSTOM_ERROR:109return 'Application custom error';110111case goog.net.ErrorCode.EXCEPTION:112return 'An exception occurred';113114case goog.net.ErrorCode.HTTP_ERROR:115return 'Http response at 400 or 500 level';116117case goog.net.ErrorCode.ABORT:118return 'Request was aborted';119120case goog.net.ErrorCode.TIMEOUT:121return 'Request timed out';122123case goog.net.ErrorCode.OFFLINE:124return 'The resource is not available offline';125126default:127return 'Unrecognized error code';128}129};130131132