Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
alexdryden opened this issue Sep 15, 2023 · 1 comment
Open

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

alexdryden opened this issue Sep 15, 2023 · 1 comment

Comments

@alexdryden
Copy link
Contributor

alexdryden commented Sep 15, 2023

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:

  • As a super user, open a book where you are not a book user
  • Go to Content tab and select Add new page
  • Add title and body and click "Save"

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:

alert('Something went wrong while attempting to save: '+message);
and here:
if (!$this->user && $this->api_users->is_super()) $this->_output_error(StatusCodes::HTTP_UNAUTHORIZED, 'You do not have permission to modify this book');

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
Copy link
Collaborator

A pull request would be excellent, thanks @alexdryden !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants