Build Custom Errors to force HTTP code 400 BAD REQUEST

When an error occurs while record creation in Netsuite via Restlet script, instead of suppressing it with try-catch modules we can selectively pass that error to build a custom error, and throwing that error will deliberately make the HTTP code to 400 bad Request.

var missingIdError = error.create({
                name: reponseJson.statusCode,
                message: reponseJson.error,
                notifyOff: true
            });

            missingIdError.toString = function () { return missingIdError.message };

            throw missingIdError;

Leave a comment

Your email address will not be published. Required fields are marked *