Instructor: The last group of status codes
we will discuss is a 500 server error.
The most common status code in this group
is a 500 internal server error.
What this status means is that something bad happened
while processing the request
and therefore the request could not be complete.
Now, note that this status does not explain specifically
what exactly happened.
It just said that something bad happened.
So the client actually can do nothing about it.
Now, this is actually a good thing
because exposing to the client what was the exact problem
poses a security risk.
Because if, for example, you will notify the client
that some SQL statement did not succeed,
then now the client knows what SQL statements you are using
to access the database and he can exploit it
to gain access to some unauthorized resources.
So the 500 is used to notify the client
that something bad happened,
and right now there is nothing the client can do
to mitigate this problem.
This is in contrast to the 400 group
where the client should do something about the error.
So if the error was that the user is not authorized,
then the user should authorize himself.
But again, with the 500 error,
there is nothing required for the client to do.
Now the 500 status is used with all verbs
and all the four verbs we discussed,
the get, put, post and delete can return 500.
There are some more status codes in the 500 group,
but actually they're usually not used
or are very low level and you should not use them.
So stick to the 500 status code and return it
when something bad happened during processing the requests.