When using code similar to this in back-end coding:
try {
// Some code here
} catch (error) {
// Handle error here
}
What are the properties associated with ‘error’? Is ‘error’ always the same object type? Is there a base type, and if so what are the properties? Should I use error.message to log a message? Will this always work without throwing another error (i.e. “unsupported property” or some such)?
Thanks!
The 2 most common are:
error.message
error.name
Others that are browser specific:
fileName (Mozilla)
lineNumber (Mozilla)
columnNumber (Mozilla)
stack (Mozilla)
description (Microsoft)
number (Microsoft)
Check the javascript error object. Wix may not have imeplemented them all.
Yeah, the reason I asked is that I got a Wix back-end error message because every place I use try…catch I either log error.message or pass that back to my back-end caller, and in some cases I am seeing there is no property “error.message” but not always…
I’ve seen example code, where error.message wasn’t used, just the error was returned, like error was a string object itself. Either that, or there might be some clever overloading of the class going on, and its smart enough to return the string, if no parameters are specified.