pjs.setError()



This API updates the values returned by pjs.status() and pjs.error() . Internally, Profound.js keeps a status code value and an error flag.

Passing false to the pjs.setError() API will set the status code to 0 and the error flag to false.

You may also pass an exception to pjs.setError(). In this case, the exception's status code will be used to update the internal status code.

Parameters
  1. Numeric status code, exception object or boolean.

Examples
pjs.setError((2 + 2) == 5);   console.log(pjs.error()); // true console.log(pjs.status()); // 999 - the default status code for errors



var pos = 0; pjs.setError(false); try { pos = 'ABC'.scan('D', 0); } catch(err) { //.scan() throws an error with a status code of 100 (Invalid start position passed to scan() method.) pjs.setError(err); //we pass in the exception } console.log(pjs.error()); // true console.log(pjs.status()); // 100