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

Display errors to user, don't just console.error them #54

Open
cheshire137 opened this issue Mar 8, 2017 · 9 comments
Open

Display errors to user, don't just console.error them #54

cheshire137 opened this issue Mar 8, 2017 · 9 comments

Comments

@cheshire137
Copy link
Owner

cheshire137 commented Mar 8, 2017

In

console.error('failed to load maps', error)
and other error handlers, we're just logging the error message in the JavaScript console. As mentioned in #46 (comment), we should also render a friendly message to the user that something went wrong. I think a new ErrorMessage component is the way to go. Here's how I imagine the flow working:

  • Some JSON response fails and one of our error handlers in ComponentForm is called. Besides console.error'ing, they should also this.setState({ error: 'description of the problem' }).
  • In the render for ComponentForm, we render <ErrorMessage error={this.state.error} />.
  • The ErrorMessage component is smart enough to render null when the error it is given is undefined/blank/null. Otherwise, it renders a <p className="text-attack">{this.props.error}</p>.
  • We could also include an 'X' button in the <p> tag of ErrorMessage that, onClick, will call some function given to it, like onDismiss. ComponentForm should pass this onDismiss prop to ErrorMessage. When it's called, ComponentForm should this.setState({ error: null }) which will result in ErrorMessage re-rendering to be empty.
@cheshire137
Copy link
Owner Author

@justbarreto and I are going to pair on this one!

@justbarreto
Copy link
Collaborator

image

Something like this? I didn't do the inline example of an input. Will work with Steph for that.

@cheshire137
Copy link
Owner Author

Yeah! That's what I had in mind. 👍

@cheshire137
Copy link
Owner Author

cheshire137 commented Mar 8, 2017

Do you have Screenhero, @justbarreto? I can hook you up with an invitation if not.

@justbarreto
Copy link
Collaborator

justbarreto commented Mar 8, 2017

I do believe I have screenhero. Haven't logged on in a while. @cheshire137 PM'ed you the email.

@RobThePM
Copy link
Collaborator

omg that screenshot looks amazing. i've been checking my email for 'updates', but havent seen anything. i'm glad i checked here! :)

@cheshire137
Copy link
Owner Author

Noooo Rob, don't believe it! That's a sample from another site, not our app.

@RobThePM
Copy link
Collaborator

Damn, rookie mistake

@RobThePM
Copy link
Collaborator

I'm okay with pushing this to version 2 if you guys want. Up to you. :)

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

3 participants