What do you do to present usable/understandable error messages to the user?
If, for instance, a user tries to upload an image and it fails, I don’t want to give them a “Error! Internal Server Error” message because this will just frustrate them.
I want to give them a clearer message that will make them understand the issue and will give them the right wording to pass onto the developer if it is a system issue.
Just to clarify, I am talking about system errors rather than validation errors.
So instead of "message: 'Some files failed to upload. Error code: 1'" we could use things like this
$upload_max_size = ini_get('upload_max_filesize');
$phpFileUploadErrors = array(
0 => 'There is no error, the file uploaded with success',
1 => 'Exceeds php.ini upload_max_filesize of '.$upload_max_size.'MB',
2 => 'The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form',
3 => 'The uploaded file was only partially uploaded',
4 => 'No file was uploaded',
6 => 'Missing a temporary folder',
7 => 'Failed to write file to disk.',
8 => 'A PHP extension stopped the file upload.',
);
Returns the exact error your server returns. There’s no way for us to know what is causing it. It could be file upload, image processing component or ANY other server side component.
Also the detailed errors appear only when debug is on.
Maybe you just want to show some standard error message or use try/catch in Server Connect for your different steps to return specific messages.
Using an array, if you want to match the code returned in the error code, you can do so using array. And this will work only when the error messages / debug are on, as @Teodor said.