this.channel.status
似乎有所有的錯誤代碼。問題是,狀態是一個數字,他們似乎沒有記錄。 Components.results
包含了一些,但不是全部,這些代碼,併爲它們分配一個常數。由於我找不到任何文檔,我想我們必須根據常數猜測出錯的原因。 SSL錯誤不在Components.results
中,可通過試用和錯誤發現。
這裏有一個函數可以獲取一些錯誤併產生一條消息。
// Call this from your AJAX error handler
self.GetAJAXFailureCode(this.channel.status);
self.GetAJAXFailureCode = function(Status){
var ERROR_CODE,ERROR_MESSAGE;
// Some, but not all can be found in Components.results.
// All the other codes appear to be undocumented, and have
// to be discovered through trial and error (thanks Mozilla.)
switch(Status){
case(2153390067):
ERROR_CODE = 'sec_error_unknown_issuer';
ERROR_MESSAGE = 'The certificate was signed by an unknown Certificate Authority (add the CA to FF to fix).';
break;
case(2153390069):
ERROR_CODE = 'sec_error_expired_certificate';
ERROR_MESSAGE = 'The SSL certificate has expired.';
break;
case(2152398879):
ERROR_CODE = 'NS_ERROR_REDIRECT_LOOP';
ERROR_MESSAGE = 'You seem to be going in circles!';
break;
case(2152398864):
ERROR_CODE = 'NS_ERROR_OFFLINE';
ERROR_MESSAGE = 'There is no network. There is only XUL.';
break;
case(2152398862):
ERROR_CODE = 'NS_ERROR_NET_TIMEOUT';
ERROR_MESSAGE = 'The network connection timed out.';
break;
case(2152398878): // This happens when the network cable is unplugged.
ERROR_CODE = 'NS_ERROR_UNKNOWN_HOST';
ERROR_MESSAGE = 'Please make sure your network cable is securely fastened, and the network is up. (Unknown Host)';
break;
default:
ERROR_CODE = 'unknown_error';
ERROR_MESSAGE = 'An error with code '+this.channel.status+' occurred. Good luck wih that.';
}
return [ERROR_CODE,ERROR_MESSAGE];
}