0

I have script and it sometimes cause 500 Internal Server Error. I can handle that errors. But which status to use in answer when this occur?

Code example in perl:

# catch error
eval {
     here is code which sometimes cause 500
     ....
     $response_body =  handle_request();
}

# Check if error occur
if( $@ ) { 
     $response_body =  'Error was handled'; 
     # Should I change status from 500?
     # If I should change. Which status I should use?
     # 200 or something else?
}


return $response_body;    

1 Answer 1

1

What do you mean, you "handled" it? Did you completely recover and the client gets their requested data? Then it should be 200.

Did you just log the exception and prevented the crash, but have no useful data to send to the client? 500 in this case.

Sign up to request clarification or add additional context in comments.

6 Comments

which of 5xx should be?
just 500, I think
500 not handy so much. I should distinguish handled and not handled. I suppose to use 599 for example. But ask before want to ask advice.
@EugenKonkov: why the client should care if it's handled or not? It didn't get stuff it requested. That's all that matters.
For client that has no matter. It has matter when admin analize logs. So he can distinguish those cases
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.