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

Have clear error messages in tooltip #6598

Open
cpandit201 opened this issue Jun 9, 2020 · 5 comments
Open

Have clear error messages in tooltip #6598

cpandit201 opened this issue Jun 9, 2020 · 5 comments

Comments

@cpandit201
Copy link

@cpandit201 cpandit201 commented Jun 9, 2020

Describe the bug
While saving a new collection type, I faced an error. Let the user know about the error description in the tooltip provided

Steps to reproduce the behavior

  1. Create a new collection type
  2. Create a UID field of MaxLength greater than 500
  3. Save the collection type
  4. See error tooltip without any clue of what happened in background,

As a dev, I thought it was an issue with my mongo atlas cluster, When checked the network logs, the concise error message indicating the root cause but was not shown in the tooltip

{"error":{"contentType.attributes.productId.maxLength":["contentType.attributes.productId.maxLength must be less than or equal to 256"]}}

Expected behavior
Let the user know in the tooltip mentioned about the error description rather than just letting user see a message "An error occoured"

Screenshots
image

System

  • Node.js version: v10.16.3
  • NPM version: 6.9.0
  • Strapi version: "strapi": "3.0.1"
  • Database: mongo-atlas
  • Operating system: osx mojave
@cpandit201 cpandit201 changed the title Let the user know about error description Have clear error messages in tooltip Jun 9, 2020
@derrickmehaffy
Copy link
Member

@derrickmehaffy derrickmehaffy commented Jun 9, 2020

@lauriejim
Copy link
Member

@lauriejim lauriejim commented Jun 16, 2020

Thank you for reporting this issue.
Can you please try to have a look in the code base of the admin of the Content Type Builder plugin.
I will appreciate your contribution on it.

@cpandit201
Copy link
Author

@cpandit201 cpandit201 commented Jun 16, 2020

Thanks for suggesting, will try to take this up

@soupette
Copy link
Member

@soupette soupette commented Jun 17, 2020

@cpandit201 @lauriejim we could easily display the errors in the content type builder by doing the following:

  1. Create a utility to display the errors in the notifications:
const displayErrors = error => {
  const errorObject = get(error, ['response', 'payload', 'error'], {});

  if (isEmpty(errorObject)) {
    strapi.notification.error('notification.error');
  }

  Object.values(errorObject).forEach(errorArray => {
    strapi.notification.error(errorArray.join(' '));
  });
};
  1. In this file we could replace the console.error({ err }) by displayErrors(err)
@Cr0s4k
Copy link
Contributor

@Cr0s4k Cr0s4k commented Sep 4, 2020

@cpandit201 @lauriejim we could easily display the errors in the content type builder by doing the following:

  1. Create a utility to display the errors in the notifications:
const displayErrors = error => {
  const errorObject = get(error, ['response', 'payload', 'error'], {});

  if (isEmpty(errorObject)) {
    strapi.notification.error('notification.error');
  }

  Object.values(errorObject).forEach(errorArray => {
    strapi.notification.error(errorArray.join(' '));
  });
};
  1. In this file we could replace the console.error({ err }) by displayErrors(err)

Started this in #7737 basing on your comment!

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

Successfully merging a pull request may close this issue.

5 participants