-
Notifications
You must be signed in to change notification settings - Fork 9
Add error handling mechanism [3h] #97
Comments
@rgrempel added some great thoughts in another (private) thread, so copied (and adapted links) here: Here are a few initial thoughts. Generally speaking, I think it's nice to delay converting stuff to strings until as late as possible. So, I wouldn't necessarily demand that the error type have some text up front ... instead, I think it would be better to model whatever we want to model about the error context, and then have some function somewhere that turns it into text (at the appropriate moment). For an example, see viewError, but of course we'll ultimately want something somewhat more sophisticated than that. Now, I think there are at least three general classes of error, as far as the UI goes.
Consider, for instance, something like this.
One way to improve on this would be something like this:
So, it's the
Or something like that -- I think that's not quite perfect. But, the general approach is, I think, correct -- i.e. that we ultimately need to track some extra information about updates in progress, which Now, given such a type, we then have everything we need to display something nicely in the UI -- exactly how to do that would depend on the context. For instance, we could immediately show the new value, but with some styling to indicate that it hasn't been sent to the server yet. Then, when the update is in progress, we could show some different styling. And if it error's, we could show some styling for the error -- perhaps an outline, and tooltip to explain, or whatever (for instance, even a popup to "retry", since we track the value we were trying to set). Anyway, once the data model is correct, it makes it easy to do what makes sense in the UI.
Anyway, those are a few thoughts. |
@rgrempel I had different thoughts about this, which involved a list of errors. But then I realized we're not just dealing with errors. Showing for example a type LogTypes
= VisibleLog WebData (WebData -> String) -- 2nd argument produces the visible string out of the data
| HiddenLog WebData
type alias Logs = List LogTypes So child components can return something like:
I think the difference in our approach is the separation of concerns. That is, once a child component has returned the log item they no longer care about it. That is, the data itself is separated from the need to log it. Then a higher component will take the List of logs, process it, and trim it down. We get some duplication of data, but keep the What do you think? |
Yes, that's consistent with my third case ... that is, errors which don't necessarily relate to some data we're currently displaying. But, you're right that it isn't necessarily just errors ... we might want to keep a "history" of what happened, so successes too. Events, you might say. So, you could imagine wanting both ... that is, you could imagine wanting an However, in defining the Now, we'll want one or more Similarly, we shouldn't really decide up front whether the event is "visible" or not -- it might be visible in one UI context and not another, for instance. We should just include whatever real data we need in order to decide later whether to make it visible in one context or another. In terms of how to structure the generation and capture of event logs in an app, your |
I'm going to tackle this one, to add the simplified error mechanism we have in other internal projects, which make errors more visible during development. |
No description provided.
The text was updated successfully, but these errors were encountered: