The generated JavaScript allows you to override the behavior of the showErrorFromNative function using the customBeforeReportErrorFromNative(errorString)and customAfterReportErrorFromNative(errorString) methods.
This shows an example of how to override or customize the error message based on the returned numeric error codes through customBeforeReportErrorFromNative.
Example 1
function customBeforeReportErrorFromNative(errorString) {
var errorCode = getURLParamFromNativeError("errCode", errorString);
// 500 and above are network errors
if ( errorCode >= 500 )
{
// Could check lang global variable if so desired
//if ( lang == ... )
{
// Show your own custom error message based on errorCode
showAlertDialog("Do you have a network connection?", "My custom error");
// return false to by pass default behavior
return false;
}
}
return true;
}
Identified error scenarios include:
- Any network related errors during an online (synchronous) request contain an error code of 500 or greater (check for >= 500)
- public static final int UNKNOWN_ERROR = 1; // "unknown error"
- public static final int ATTACHMENT_NOT_DOWNLOADED = 100; //"Attachment has not been downloaded"
- public static final int UNKNOWN_MIME_TYPE = 101; //"Unknown MIME type"
- public static final int FILENAME_NO_EXTENSION = 102; //"File name without extension"
- public static final int REQUIRED_PARAMETER_NOT_AVAILABLE = 103; //"Required parameter is not available"
- public static final int UNSUPPORTED_ATTACHMENT_TYPE = 105; //attachment type is not supported
- public static final int SSOCERT_EXCEPTION = 106; //SSO Certificate manager exception
- public static final int FAIL_TO_SAVE_CREDENTIAL = 107; //Fail to save credential
- public static final int FAIL_TO_SAVE_CERTIFICATE = 108; //Fail to save certificate
- public static final int DEVICE_NOT_CONNECTED = 109; //Device is not connected