Scripting errors

Script Application, Script Node, the derivates of ScriptNode, and Script Result Set use a standard set of error fields. They also provide a standard set of methods for setting and retrieving error states.

Error conventions

An error is made up of the following:

  • An integer errorNumber. The most common of these are:
    • 0 - success
    • 100 - general error
    • 101 - not authorised
    • 102 - not found
    • 103 - parameter error
    • 105 - user error
    • 106 - state error
    • 108 - impact warning
    • 109 - impact error
  • An errorDescription. This is a technical description of an error.
  • An errorMessage. This is a user-friendly description of the message. It is only passed back when error number is 105.
  • An list of fields in error held in errorFields. This is to allow the UI to determine which fields should be highlighted as in error. It is only passed back when error number is 105.

Error methods

resetError()Reset all error fields

Setting errors

setErrorNumber(int) Set the error number.
setErrorDescription(String) Set the error description. 
setErrorMessage(String) Set the error message.
setErrorFields(String) Set the error fields. 
setError([errorNumber,]errorDescription[,errorMessage[,errorFields]]) Set an error.
mergeError([errorNumber,]errorDescription[,errorMessage[,errorFields]]) Set an error if no error has already been set. If error 105 is set, it is overridden by any error other than error 105. If error 105 is set and another error 105 is merged, the error fields are concatenated.
setUserError(errorDescription,[errorMessage[,errorFields]]) set a user error. Same as calling setError with the first parameter as 105.
mergeUserError(errorDescription[,errorMessage[,errorFields]]) merge a user error. Same as calling mergeError with the first parameter as 105.
setError(object) Set error state from another object.
mergeError(object) Merge error state from another object.
resetError() Reset all error fields. 

Getting errors

int = getErrorNumber() Get the error number.
String = getErrorDescription() Get the error description. 
String = getErrorMessage() Get the error message. 
String = getErrorFields() Get the error fields. 
boolean = errorFound() Returns true if an error has been found, i.e. if error number is not zero 
getErrorNumberDescription() If there is no error, return "". If there is an error, return "Error nnn: xxx", where nnn is the error number, and xxx is the description. Useful for logging errors.
getErrorFull() Get all of the error information. Useful for debugging.