Unclear error handling
See original GitHub issueIs your feature request related to a problem? Please describe. I’m learning Fritz2, and I’m making a login form. When user enters bad credentials, and the API returns HTTP 401, I’d like to show the error (toast). I can’t find a way how.
Another related issue is in Tracker
. When I start the remote request, and it fails, the button keeps spinning and I couldn’t find any method how to stop it.
Describe the solution you’d like
- Make special chapter in documentation about error handling.
- Demonstrate it in remotes example.
- I have uBlock, which blocks the request to the domain you use in this example. I see the error in developer console, but nothing in the UI.
Abouty the tyracker problem, I’d suggest to change the track
method like this:
// OLD (0.10.1)
return operation().also { state.value = null }
// NEW
return try { operation() } finally { state.value = null }
Describe alternatives you’ve considered I couldn’t find any. Just provide some documentation and example.
Additional context My handler looks like this. If you could show me how to display the error toast, I’d be grateful.
val login = handle { model ->
loading.track {
if (validator.isValid(model, Unit)) {
try {
http("/apiIs2/authUser")
.acceptJson()
.contentType("application/json")
.body(
JSON.stringify(
json(
"username" to model.login, "password" to model.password
)
)
)
.post()
.getBody()
router.navTo("main")
} catch (t: Throwable) {
console.log(t)
toast { // NOT DISPLAYED :(
content {
alert {
title("Login error")
content(
if (t is FetchException && t.statusCode == 401.toShort()) {
"Bad credentials"
} else {
"$t"
}
)
}
}
}
}
}
model
}
}
Issue Analytics
- State:
- Created 2 years ago
- Comments:6
Top Results From Across the Web
Error Messages: Examples, Best Practices & Common Mistakes
1. Write for humans (be understandable) · 2. Make sure the message is helpful · 3. Use a touch of humor · 4....
Read more >How to Write Good Error Messages - UX Planet
1. Be Clear And Not Ambiguous ... Write error message in clear and simple language. User should be able to understand the problem...
Read more >Best 10 Examples And Guidelines For Error Messages
Here are ten basic guidelines to help you create the most effective error messaging for your users. Click here to see all of...
Read more >Unclear behavior at specific error handling - Stack Overflow
I'm trying to handle specific errors but I'm surprised about the behavior. ... it returns true , even if err is nil ....
Read more >How to Write Good Error Messages - UX Design World
If the error message is ambiguous and the user is not able to find the reason for the message, then it is of...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Ok, I have to correct myself: Of course it is quite easy to make
track
safe for unsafe operations.I already provided PR #430 to improve this situation!
I display my errors like this: