Modified error management to comply with HTTP error codes