Hello there,
Our team has creating new private app, We are using API KEY auth. All was working good but I was validating the api key from our api getting proper response codes from api. When i get 200 response code connection will be created and when i get error response codes, it shows me message that error occured, but then why a connection is created even it was showing error. I’ve tried handling this with error handler ( throw the error ), tried many things but cannot be able to fix this issue.
Here is the Code

the error handled here with 404 code.

Even after error handling the connection was created.

Please help me to figure out what I am doing wrong here.
Thanks in advance