Presenting usable error messages to the user

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.

dmx-on:error="notifies1.danger('Error! '+lastError.message)"

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.

Do any of you have a good solution?

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.',
);

and any others

that can be found here https://www.php.net/manual/en/features.file-upload.errors.php

1 Like
lastError.message

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.

Thanks for your guidance @Teodor, I was wondering what others did and if there were any clever ideas.

Maybe using Server Connect names or variables based on Form names etc.

Hi Teodor, is there any way to get these 5 lines to show?

image

in the

dmx-on:error="notifies1.danger('Error! '+lastError.message)"

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.

1 Like