question on 2.1 scripts, `throw new Error('blah......
# suitescript
c
question on 2.1 scripts,
throw new Error('blah...');
causes a
System	UNEXPECTED_ERROR	7/17/2020	12:05 pm	dsnetsuite test0	An unexpected SuiteScript error has occurred
Is that supposed to happen? Are we not allowed to manually throw errors? This used to cause the script to bubble the error up and we would see the
'blah...'
in the error logs.
b
what sort of script are you using
if its map/reduce, i wouldnt be surprised if its a bug where they didnt add serialization to the 2.1 Error object
c
restlet
making a call into another module...
both labeled 2.1
Can't
throw
at all without
UNEXPECTED_ERROR
c
We use
throw
in 2.1 Suitelets, User Events, and RESTlets based on a quick search of our repo. I'll double-check with my teammates, but AFAIK there aren't any issues.
In the RESTlets, it looks like we're doing
Copy code
~throw error.create( options );~
Sorry, those turned out to be 2.x
But we are throwing manual errors in Suitelet and User Events 2.1
b
probably support case issue
potentially @Ashwin K. can help out
✔️ 1
🙏 1
c
If I switch my 
@NApiVersion 2.1
  to 
@NApiVersion 2.0
 it works as expected.
c
I just performed a quick test, and with a 2.1 RESTlet, I'm able to throw an error like so:
Copy code
if ( param === 'error' ) {
  throw {
    code: '500',
    message: 'Testing throw'
  }
}
which is caught and handled as I expect
likewise
throw Error('Testing throw')
1
b
might depend on what entry point you are using and potentially content type
a simple GET with no content type fails on 2.1 with unexpected errors