anvc / scalar

Born-digital, open source, media-rich scholarly publishing that’s as easy as blogging.
Other
231 stars 73 forks source link

Error message returns "object Object" to user in alert #220

Open alexdryden opened 1 year ago

alexdryden commented 1 year ago

Summary: While testing a feature we are working on, we found a few places where alert messages sent to the user don't contain the custom error message.

Steps to reproduce:

Behavior expected: Error message alert with text: "Something went wrong while attempting to save: You do not have permission to modify this book". Behavior observed: Error message alert with text : "Something went wrong while attempting to save: object Object"

Message contents are here: https://github.com/anvc/scalar/blob/a9165f1fc34d0834b911c11757b92fc47b9d15bf/system/application/views/arbors/html5_RDFa/js/form-validation.js#L301 and here: https://github.com/anvc/scalar/blob/a9165f1fc34d0834b911c11757b92fc47b9d15bf/system/application/controllers/api.php#L111

The pattern that I see elsewhere for this kind of message reporting is message.responseJSON.error.message[0].value; which gets the message contents from the jqXHR response object, and I can submit that as a pr with the fixes for the other error message reporting bug if that looks good to you.

craigdietrich commented 1 year ago

A pull request would be excellent, thanks @alexdryden !