urlopen.open() error responses
The urlopen.open() API receives error codes that provide information to help you recover from some errors.
The urlopen.open() API can receive error information that can reveal problems with servers and connections. This information is found in the GatewayScript error object that is returned in the callback function. When an exception is encountered, the GatewayScript API that is running can catch the error and handle it as part of the action execution. The exception results in an error that is posted to the document processing runtime and logged to the logging infrastructure. Users can determine whether an error is encountered during the connection by testing the error object. If no error is found, you can read the status code, response message, and response headers.
var urlopen = require ('urlopen');
// open connection to target
urlopen.open("http://somserver", function (error, response) {
// handle the error when connecting to target
if (error) throw error;
// populate json
response.readAsJSON ( function (error, json) {
// handle the error when reading from target or JSON parsing
if (error) throw error;
// write json to log
console.log (json);
// write json to output context
session.output.write (json);
});
});ulropen.open() errors can be grouped by their general cause.- Connection errors
- Errors that occur when GatewayScript attempts to establish a connection with the target of the
urlopen.open() API.
- Invalid ip/domain (host not found)
- DNS Lookup failure
- DNS Lookup ok, not listening on desired port
- error TLS Backend certificate is not trusted
Optionserrors- Errors that occur due to incorrect content in the request
optionsparameter of the urlopen.open() API.- Null connection options
- Incorrect urlopen options: undefined
- No target
- Invalid port/URI (unknown service port)
- Unsupported service/protocol
- Incorrect urlopen options: target not a string
- Incorrect urlopen options: invalid HTTP method
- Incorrect urlopen options: invalid HTTP method object type
- Incorrect urlopen options: invalid content type
- API usage
- Errors that are due to an incorrect urlopen.open() call.
- Wrong number of params for the url open function
- url open callback is not a function
- Errors with the remote server
- Errors that are due to condition detected by the urlopen.open() API.
- Timeout error on url open