Operating system error

An operating system error occurs when a packet does not reach its intended destination. The possible causes are: There is no network - no connected network and cannot be routed to the destination host - mainly because the destination host may be on an isolated network or offline. The result of. There is no application listening to the destination port - the specified port number will be sent when the request arrives at the destination host. If the server is not listening for the port number or too many requests are queued, the connection request will be rejected. Unable to resolve target hostname - URL loading system returns an error. Typically these errors are caused by configuration errors or attempts to access hosts that have no external name resolution and are on an isolated network. In iOS's URL loading system, operating system errors are sent to the application as an NSError object. Ios uses NSError to transmit error messages in software. The main advantage of using NSError is that NSError objects include error field attributes; Many network request problems are caused by network disconnection, so we need to check each time we make a network request. Because mobile devices move off the network. Here we usually use Reachability.Copy the code

HTTP error

HTTP error because of HTTP request. An httpServer or application Server problem. HTTP errors are sent to the requesting client using the status code of the HTTP response.

Class 5 HTTP errors

  • Level 100 of information nature – Information from httpServer, processing of the request will continue, but with a warning.
  • Level 200 of success – Service please accept the request.
  • Redirection required level 300 – the resource has moved and needs to be redirected.
  • Client error level 400 – Indicates that the client sends data that the server does not properly handle, such as incorrect HTTP headers causing this range of errors.
  • Downstream Error level 500 – Indicates an error occurred between httpServer and downstream application Server.

Application error

These errors are caused by business logic and applications executing above the service layer.

The error could be a code problem, such as an exception, or a semantic problem. B direction service provided invalid account number, etc.

For example, if you have 500 yuan in your bank card and you want to withdraw 1,000 yuan in cash, an error will occur.

Common network request error code

  • (NSString *)networkErrorInfo

{

    NSError * err;

    NSString *errorMsg;

    switch (err.code) {

        case -1://NSURLErrorUnknown

ErrorMsg = @” invalid URL “;

        break;

\

        case -999://NSURLErrorCancelled

ErrorMsg = @” invalid URL “;

        break;

\

        case -1000://NSURLErrorBadURL

ErrorMsg = @” invalid URL “;

        break;

\

        case -1001://NSURLErrorTimedOut

ErrorMsg = @” network not working, please try again later “;

        break;

\

        case -1002://NSURLErrorUnsupportedURL

ErrorMsg = @” unsupported URL “;

        break;

\

        case -1003://NSURLErrorCannotFindHost

ErrorMsg = @” can’t find server “;

        break;

\

        case -1004://NSURLErrorCannotConnectToHost

ErrorMsg = @” failed to connect to server “;

        break;

\

        case -1103://NSURLErrorDataLengthExceedsMaximum

ErrorMsg = @” Request data length exceeded the maximum “;

        break;

\

        case -1005://NSURLErrorNetworkConnectionLost

ErrorMsg = @” Network connection error “;

        break;

\

        case -1006://NSURLErrorDNSLookupFailed

ErrorMsg = @”DNS query failed “;

        break;

\

        case -1007://NSURLErrorHTTPTooManyRedirects

ErrorMsg = @”HTTP request redirection “;

        break;

\

        case -1008://NSURLErrorResourceUnavailable

ErrorMsg = @” Resource unavailable “;

        break;

\

        case -1009://NSURLErrorNotConnectedToInternet

ErrorMsg = @” No network connection “;

        break;

\

        case -1010://NSURLErrorRedirectToNonExistentLocation

ErrorMsg = @” Redirect to a location that does not exist “;

        break;

\

        case -1011://NSURLErrorBadServerResponse

ErrorMsg = @” Server response error “;

        break;

\

        case -1012://NSURLErrorUserCancelledAuthentication

ErrorMsg = @” User cancels authorization “;

        break;

\

        case -1013://NSURLErrorUserAuthenticationRequired

ErrorMsg = @” user authorization required “;

        break;

\

        case -1014://NSURLErrorZeroByteResource

ErrorMsg = @” 0 bytes resource “;

        break;

\

        case -1015://NSURLErrorCannotDecodeRawData

ErrorMsg = @” can’t decode raw data “;

        break;

\

        case -1016://NSURLErrorCannotDecodeContentData

ErrorMsg = @” cannot decode content data “;

        break;

\

        case -1017://NSURLErrorCannotParseResponse

ErrorMsg = @” failed to parse response “;

        break;

\

        case -1018://NSURLErrorInternationalRoamingOff

ErrorMsg = @” International roaming closed “;

        break;

\

        case -1019://NSURLErrorCallIsActive

ErrorMsg = @” called activated “;

        break;

\

        case -1020://NSURLErrorDataNotAllowed

ErrorMsg = @” data not allowed “;

        break;

\

        case -1021://NSURLErrorRequestBodyStreamExhausted

ErrorMsg = @” “;

        break;

\

        case -1100://NSURLErrorFileDoesNotExist

ErrorMsg = @” File does not exist “;

        break;

\

        case -1101://NSURLErrorFileIsDirectory

ErrorMsg = @” File is a directory “;

        break;

\

        case -1102://NSURLErrorNoPermissionsToReadFile

ErrorMsg = @” no permission to read files “;

        break;

\

        case -1200://NSURLErrorSecureConnectionFailed

ErrorMsg = @” Security connection failed “;

        break;

\

        case -1201://NSURLErrorServerCertificateHasBadDate

ErrorMsg = @” Server certificate invalid “;

        break;

\

        case -1202://NSURLErrorServerCertificateUntrusted

ErrorMsg = @” untrusted server certificate “;

        break;

\

        case -1203://NSURLErrorServerCertificateHasUnknownRoot

ErrorMsg = @” unknown Root server certificate “;

        break;

\

        case -1204://NSURLErrorServerCertificateNotYetValid

ErrorMsg = @” Server certificate is not valid “;

        break;

\

        case -1205://NSURLErrorClientCertificateRejected

ErrorMsg = @” Client certificate rejected “;

        break;

\

        case -1206://NSURLErrorClientCertificateRequired

ErrorMsg = @” Client certificate required “;

        break;

\

        case -2000://NSURLErrorCannotLoadFromNetwork

ErrorMsg = @” can’t get from network “;

        break;

\

        case -3000://NSURLErrorCannotCreateFile

ErrorMsg = @” file cannot be created “;

        break;

\

        case -3001://  NSURLErrorCannotOpenFile

ErrorMsg = @” can’t open file “;

        break;

\

        case -3002://NSURLErrorCannotCloseFile

ErrorMsg = @” can’t close file “;

        break;

\

        case -3003://NSURLErrorCannotWriteToFile

ErrorMsg = @” cannot write to file “;

        break;

\

        case -3004://NSURLErrorCannotRemoveFile

ErrorMsg = @” can’t delete file “;

        break;

\

        case -3005://NSURLErrorCannotMoveFile

ErrorMsg = @” can’t move file “;

        break;

\

        case -3006://NSURLErrorDownloadDecodingFailedMidStream

ErrorMsg = @” Failed to download decoded data “;

        break;

\

        case -3007://NSURLErrorDownloadDecodingFailedToComplete

ErrorMsg = @” Failed to download decoded data “;

        break;

    }

    return errorMsg;

}

HTTP error 400

400 Request error The server cannot understand the request due to incorrect syntax. Without modification, the client cannot repeat the request.

HTTP error 401

401.1 Unauthorized: Login failed This error indicates that the certificate transferred to the server does not match the certificate required to log in to the server. Contact the administrator of the Web server to confirm that you have access to the requested resource. 401.2 Unauthorized: Login Fails due to server configuration This error indicates that the certificate transferred to the server does not match the certificate required for login to the server. This error is usually caused by not sending the correct WWW validation header field. Contact the administrator of the Web server to confirm that you have access to the requested resource. 401.3 Unauthorized: Unauthorized due to ACLs in resources This error indicates that the certificate transferred by the customer does not have access to a specific resource on the server. This resource could be a Web page or file listed in the address line in the client, or it could be another file on the server needed to process the file listed in the address line in the client. Record the full address you are trying to access, and contact the administrator of the Web server to confirm that you have access to the requested resource. 401.4 Unauthorized: Authorization service rejected by filter This error indicates that a filter has been installed on the Web server to authenticate users connecting to the server. This filter denies access to authenticity certificates connected to this server. Record the full address you are trying to access, and contact the administrator of the Web server to confirm that you have access to the requested resource. 401.5 Unauthorized: Authorization for ISAPI/CGI applications failed This error indicates that the address in the Web server you are trying to use has an ISAPI or CGI program installed to verify the user’s credentials before continuing. This program denies access to the authenticity certificate used to connect to the server. Record the full address you are trying to access, and contact the administrator of the Web server to confirm that you have access to the requested resource

HTTP error 403

403.1 Forbid: Forbid execution access This error can be caused if CGI, ISAPI, or other executables are executed from a directory that does not allow execution. If the problem persists, contact your Web server administrator. 403.2 Forbidden: Forbidden to read access This error occurs when there is no default web page available or directory browsing that is not enabled for this directory, or when you try to display HTML pages that reside in a directory marked only with execute or script permissions. If the problem persists, contact your Web server administrator. 403.3 Deny: Deny write Access This problem occurs when you attempt to upload or modify files in a directory that is not allowed write access. If the problem persists, contact your Web server administrator. 403.4 Forbidden: SSL required This error indicates that the web page you are trying to access is protected by secure Sockets Layer (SSL). To view, you must enable SSL by typing https://before the address you are trying to access. If the problem persists, contact your Web server administrator. 403.5 Forbidden: SSL 128 Required This error message indicates that the resource you are trying to access is protected by 128-bit Secure Sockets Layer (SSL). To view this resource, you need a browser that supports this SSL layer. Make sure your browser supports 128-bit SSL security. If so, contact the administrator of the Web server and report the problem. 403.6 Deny: Deny IP Addresses This problem occurs if the server has a list of IP addresses that are not allowed to access this site and the IP address you are using is in this list. If the problem persists, contact your Web server administrator. 403.7 Forbidden: Requires User Certificate This problem occurs when attempting to access a resource that requires the browser to have a user secure Sockets Layer (SSL) certificate that is recognized by the server. Can be used to verify that you are a legitimate user of this resource. Contact the administrator of the Web server for a valid user certificate. 403.8 Forbid: Forbid site access This problem occurs when the Web server does not service the request or you do not have permission to connect to the site. Contact the administrator of the Web server. 403.9 Access Denied: Too many Users Connected This problem can occur if the Web is too busy and unable to process your requests due to heavy traffic. Please connect again later. If the problem persists, contact your Web server administrator. 403.10 Access Forbidden: Configuration Invalid The configuration of the Web server is incorrect. If the problem persists, contact your Web server administrator. 403.11 Access denied: Password changed This error occurs when a user enters an incorrect password during authentication. Please refresh the page and try again. If the problem persists, contact your Web server administrator. 403.12 Access Denied: Mapper denies access Denies user certificate attempts to access this Web site. Contact your site administrator to establish user certificate permissions. You can also change the user certificate and try again if necessary.

HTTP error 404

404 Not Found The Web server could not find the file or script you requested. Check the URL to make sure the path is correct. If the problem persists, contact your server administrator.

HTTP error 405

405 Disallow this method The method specified in the request line is not allowed for the resource identified by the request. Make sure the correct MIME type is set for the requested resource. If the problem persists, contact your server administrator.

HTTP error 406

406 Unacceptable According to the “Accept” heading sent in this request, the resource identified by this request can only generate response entities whose content characteristics are “Unacceptable”. If the problem persists, contact your server administrator.

HTTP error 407

**407 requires proxy authentication ** You must authenticate this proxy server before you can serve this request. Please log in to the proxy server and try again. If the problem persists, contact your Web server administrator.

HTTP error 412

412 Prerequisites Failed When testing prerequisites on the server, the preconditions given in part of the request title field are estimated to be FALSE. The client places the prerequisite in the current resource metainFormation (header field data) to prevent the requested method from being misapplied to another resource. If the problem persists, contact your Web server administrator.

HTTP error 414

**414 Request-URI too long ** Request-URL too long, server refused to service this Request. This condition is only possible if the client mistakenly converts a POST request into a GET request with longer query information. The customer encountered redirection problems (for example, redirected prefixes pointing to their own suffixes). Servers are being disrupted by customers trying to exploit security vulnerabilities in some servers that use fixed-length buffers to read or execute request-URIs. If the problem persists, contact your Web server administrator.

HTTP error 500

500 Server internal error The Web server could not execute this request. Please retry this request later. If the problem persists, contact your Web server administrator.

HTTP error 501

501 Not Implemented The Web server does not support the functionality required to implement this request. Check for errors in the URL, and if the problem persists, contact your Web server administrator.

HTTP error 502

502 Gateway error When acting as a gateway or proxy, the server will receive an invalid response from the upstream server accessed while attempting to fulfill the request. If the problem persists, contact your Web server administrator

Appendix Common URL error


typedef enum NSURLError{

    NSURLErrorUnknown = -1,

    NSURLErrorCancelled = -999,

    NSURLErrorBadURL = -1000,

    NSURLErrorTimedOut = -1001,

    NSURLErrorUnsupportedURL = -1002,

    NSURLErrorCannotFindHost = -1003,

    NSURLErrorCannotConnectToHost = -1004,

    NSURLErrorDataLengthExceedsMaximum = -1103,

    NSURLErrorNetworkConnectionLost = -1005,

    NSURLErrorDNSLookupFailed = -1006,

    NSURLErrorHTTPTooManyRedirects = -1007,

    NSURLErrorResourceUnavailable = -1008,

    NSURLErrorNotConnectedToInternet = -1009,

    NSURLErrorRedirectToNonExistentLocation = -1010,

    NSURLErrorBadServerResponse = -1011,

    NSURLErrorUserCancelledAuthentication = -1012,

    NSURLErrorUserAuthenticationRequired = -1013,

    NSURLErrorZeroByteResource = -1014,

    NSURLErrorCannotDecodeRawData = -1015,

    NSURLErrorCannotDecodeContentData = -1016,

    NSURLErrorCannotParseResponse = -1017,

    NSURLErrorFileDoesNotExist = -1100,

    NSURLErrorFileIsDirectory = -1101,

    NSURLErrorNoPermissionsToReadFile = -1102,

    NSURLErrorSecureConnectionFailed = -1200,

    NSURLErrorServerCertificateHasBadDate = -1201,

    NSURLErrorServerCertificateUntrusted = -1202,

    NSURLErrorServerCertificateHasUnknownRoot = -1203,

    NSURLErrorServerCertificateNotYetValid = -1204,

    NSURLErrorClientCertificateRejected = -1205,

    NSURLErrorClientCertificateRequired = -1206,

    NSURLErrorCannotLoadFromNetwork = -2000,

    NSURLErrorCannotCreateFile = -3000,

    NSURLErrorCannotOpenFile = -3001,

    NSURLErrorCannotCloseFile = -3002,

    NSURLErrorCannotWriteToFile = -3003,

    NSURLErrorCannotRemoveFile = -3004,

    NSURLErrorCannotMoveFile = -3005,

    NSURLErrorDownloadDecodingFailedMidStream = -3006,

    NSURLErrorDownloadDecodingFailedToComplete = -3007

};

Copy the code