HTP. - HTTP Operations

<< Click to Display Table of Contents >>

Navigation:  3. Script Language > Internet and Network > HTP. - Command >

HTP. - HTTP Operations

HTP.GetErrText

Previous Top Next


SPR Script Language

 

HTP.GetErrText

Returns the error message text for a given HTTP error code.

 

Intention

 

The HTP.GetErrText command translates a numeric HTTP error code into a human-readable error message in SPR. You provide an error code (e.g., $$CODE as "12029"), and it returns a description (e.g., "Cannot connect to the server"), optionally storing it in $$RET. This helps debug issues from HTP.Request or HTP.ReqShort by explaining what went wrong.

 

It’s like a translator for your robot’s network troubles—HTP.GetErrText turns cryptic error numbers into clear messages, making it easier to fix connection or security issues.

 

Illustration

🚨 Error Code: HTP.GetErrText|12029|$$ERR sets $$ERR to "Cannot connect to the server".
📢 Debug: Display it to understand why a request failed!

 

Syntax

 

HTP.GetErrText|$$CODE[|$$RET]

 

Parameter Explanation

 

P1 - $$CODE - (Variable, Numeric)

The HTTP error code to translate (e.g., $$CODE as "12029"). Required; corresponds to WinHTTP or Internet error constants.

 

P2 - $$RET - (Variable, String, Optional)

The variable to store the error message (e.g., $$RET). If omitted, the message is returned but not stored.

 

Error Code List:

 

12002 (ERROR_INTERNET_TIMEOUT) - The request has timed out.

12029 (ERROR_INTERNET_CANNOT_CONNECT) - Cannot connect to the server.

12007 (ERROR_INTERNET_NAME_NOT_RESOLVED) - The server name could not be resolved.

12032 (ERROR_INTERNET_CONNECTION_ABORTED) - The connection with the server has been terminated.

12031 (ERROR_INTERNET_CONNECTION_RESET) - The connection with the server has been reset.

12005 (ERROR_INTERNET_INVALID_URL) - Invalid URL format.

12150 (ERROR_INTERNET_SEC_CERT_DATE_INVALID) - The date on the SSL certificate is invalid.

12152 (ERROR_INTERNET_SEC_CERT_CN_INVALID) - The SSL certificate common name does not match.

12169 (ERROR_INTERNET_SEC_CERT_REV_FAILED) - Revocation of the SSL certificate failed.

12170 (ERROR_INTERNET_SEC_CERT_REVOKED) - The SSL certificate has been revoked.

12179 (ERROR_INTERNET_SEC_CERT_WEAK_SIGNATURE) - The SSL certificate uses a weak signature algorithm.

12180 (ERROR_INTERNET_SECURITY_CHANNEL_ERROR) - The security channel could not be established.

12057 (ERROR_INTERNET_SERVER_UNREACHABLE) - The server is unreachable.

12017 (ERROR_INTERNET_LOGIN_FAILURE) - Login failed for the specified credentials.

12001 (ERROR_INTERNET_NOT_INITIALIZED) - WinHTTP is not initialized.

12039 (ERROR_INTERNET_PROXY_SERVER_UNREACHABLE) - The proxy server is unreachable.

12163 (ERROR_INTERNET_REDIRECT_SCHEME_CHANGE) - The redirect requires a protocol change (HTTP to HTTPS, etc.).

12037 (ERROR_INTERNET_DISCONNECTED) - The internet connection is currently unavailable.

12172 (ERROR_WINHTTP_CANNOT_CONNECT) - Cannot connect to the server.

12174 (ERROR_WINHTTP_CONNECTION_ERROR) - A connection error occurred.

12151 (ERROR_WINHTTP_INCORRECT_HANDLE_STATE) - The handle is in the wrong state for the requested operation.

12153 (ERROR_WINHTTP_INCORRECT_HANDLE_TYPE) - The handle type is invalid.

12157 (ERROR_WINHTTP_INVALID_URL) - The URL format is invalid.

12154 (ERROR_WINHTTP_LOGIN_FAILURE) - Login to the server failed.

12155 (ERROR_WINHTTP_OPERATION_CANCELLED) - The operation was canceled.

12166 (ERROR_WINHTTP_REDIRECT_FAILED) - The redirect failed.

12168 (ERROR_WINHTTP_RESEND_REQUEST) - The request must be resent.

12175 (ERROR_WINHTTP_SECURE_FAILURE) - A secure connection error occurred.

12156 (ERROR_WINHTTP_SHUTDOWN) - WinHTTP is shutting down.

12158 (ERROR_WINHTTP_TIMEOUT) - The request timed out.

12159 (ERROR_WINHTTP_UNRECOGNIZED_SCHEME) - The URL scheme is not recognized.

Other (default) - Unknown error: [code] (Hex: [hex])

 

Examples

 

'***********************************

' HTP.GetErrText - Sample 1: Timeout Error

'***********************************

HTP.GetErrText|12002|$$ERR

MBX.Error: $$ERR (shows "The request has timed out.")

MBX.Ready

'

'***********************************

' HTP.GetErrText - Sample 2: SSL Cert Error

'***********************************

HTP.GetErrText|12150|$$ERR

PRT.SSL Error: $$ERR (shows "The date on the SSL certificate is invalid.")

MBX.Ready

'

'***********************************

' HTP.GetErrText - Sample 3: Unknown Error

'***********************************

HTP.GetErrText|99999|$$ERR

MBX.Unknown: $$ERR (shows "Unknown error: 99999 (Hex: 1869F)")

MBX.Ready

'

 

Remarks

 

- Use after HTP.Request or HTP.ReqShort to interpret error codes returned.

- Error codes are WinHTTP/Internet constants; see list for specific meanings.

- Unknown codes return a formatted string with decimal and hex values.

 

Limitations

 

- Limited to predefined WinHTTP/Internet error codes; others get a generic message.

- No additional context beyond the error code itself.

- Assumes codes match WinHTTP constants; custom errors need manual handling.

 

See also:

 

HTP.Request

HTP.ReqShort

HTP.ClrErr