-
Notifications
You must be signed in to change notification settings - Fork 70
Legacy Error Handling
Errors will happen in two different ways:
These errors are generated before the toolkit is able to contact the OpenSRS API. The errors are produced as PHP warnings or notices which would need to be captured.
To capture and deal with these PHP warnings and notices use set_error_handler: http://us.php.net/manual/en/function.set-error-handler.php
This will set up a function to process the errors and either log them or display a custom error to the user.
Error types:
Incomplete config file
- Required information is missing in the config file. The error will include what parameter is missing.
Unable to establish socket
- Cannot create a network socket, probably due to network config error.
Authentication Error
- Unable to authenticate with OpenSRS API, check to make sure that the private key and reseller username are correct
Reseller username or osrs_key is incorrect, please check the config file.
- Same as above
Read buffer is empty. Please make sure IP is whitelisted in RWI and check the osrs_key in the config file.
- The OpenSRS system did not return any information. If the application is using SSL to connect then there may be a network issue where the data cannot be read. This is also caused by not having the machine IP whitelisted for the API. Please see section 2.1.1 for information on how to whitelist an IP.
UNEXPECTED READ: Unable to parse HTTP response code.
- Response was not provided in HTTP 1.1 format. Usually this is caused by the same reasons as above.
UNEXPECTED READ: Error reading HTTP header.
- Could not read the HTTP header at all, possibly due to dropped connection during return.
No Content-Length header returned.
- Content length header was blank. This could also happen if the IP address of the machine is not whitelisted in OpenSRS. See section 2.1.1 for information on whitelisting an IP.
- This will be the most common case of this error
UNEXPECTED READ: No Content-Length.
- Generated by an unexpected read of the content length header.
- Most likely caused by the same issues as the above error, or could be an issue with the header being corrupted.
UNEXPECTED ERROR: No Content-Length header provided!
- Same causes as above
- Generated when the Content-Length should always be provided
UNEXPECTED READ: No CRLF
- No carriage return provided after the header, possibly corrupted information due to a dropped connection.
Unable to find library directory DIRECTORY,
- Caused usually by an incorrect path in openSRS_config.php.
- Double check all paths in that file to make sure they are correct.
- Directory that is affected will be listed in the error instead of DIRECTORY.
Unable to find library file FILE,
- Same as above, but for a specific library file.
- Filename will be listed in the error instead of FILE.
Unable to find the function passed.
- The Toolkit could not find the function that was passed in the call string. This could be caused by a misspelling of the function or the configuration paths are not set correctly. Check the spelling of the function against the list in Section 8 of this document and check the paths in openSRS_config.php.
PARAMETER not defined
- This is the most common error.
- Caused by the required parameters not being passed through to the function. Please check the OpenSRS API documentation to see what is required for each function. The page numbers for each function are listed in Section 8 of this document
Incorrect call
- At least one required parameter was not passed, the call will not be made to the OpenSRS API. There will be at least one not defined error before this error.
Mail System Write Error
- The toolkit was unable to write to the server specified, please check that the mail server name is correct in the config and that the network will allow sending data to that server.
If the error happened on the OpenSRS API side, information will be passed back in the returned object.
If the command was successful then resultRaw['is_success'] on the returned object will be set to '1'. If there is an error then it will be set to 0. The exact error code is avaliable under resultRaw['response_code'] and the full error text under resultRaw['response_text']. The response codes from the OpenSRS API are listed in the API documentation at:
http://opensrs.com/docs/opensrs_xmlapi.pdf
The response codes from the Mail APP are listed in the documentation at:
http://opensrs.com/docs/OpenSRS_APP_Dev_Guide.pdf
Example:
$openSRS_results=processOpensrs("json",json_encode($callString));
if ($openSRS_result->resultFullRaw['is_success']=="0"){
echo "There was an OpenSRS error. The error code is: ";
echo $openSRS_results->resultFullRaw['response_code'];
echo " The error text is: ";
echo $openSRS_results->resultFullRaw['response_text'] . "\n";
} else {
echo $openSRS_result->resultFormatted;
}