Throw error message in pre request script is not working

pm.sendRequest(options, function (err, res) {
    if (res.code == 400) {
        throw new Error("Invalid");
      }
    else{
    pm.request.headers.add({
    key: "Authorization",
    value: 'Bearer '+res.json().access_token
});}
});
Response: There was an error in evaluating the Pre-request Script:Error: Invalid

Version: 9.7.1
OS. Windows

@spacecraft-geologis4 it does what it was asked , it throws the error “invalid” as the status was 400 .

so you get the mentioned error. saying “invalid” . Try changing the error message :tada::tada:

Let us know if you were looking for something else

@praveendvd
How to ignore

Response: There was an error in evaluating the Pre-request Script:

in the error response. Need to print only Error: Invalid