I am doing an dropbox.js upload. I am checking for errors on the server and returning them to my frontend via json. So far so good.
header('HTTP/1.1 500 Internal Server Error');
header('Content-Type: application/json; charset=UTF-8');
die(json_encode(array('message' => 'ERROR', 'code' => 100)));
on my frontend I can catch the error and do some nice stuff to alert the user
error: function(file, errorMessage, xhr) {
console.log(xhr);
// catch the error and alert the user
}
The problem is the errors are not really 'server errors' so how should I return them in the header? A 500 does not seem appropriate. It does not I suppose really matter but would nice to return the right type of error.
The kind of errors include
- filename is not unique
- wrong file type
- file is too large
What is the best status code to use?
Thanks.