You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/ADR-10-Callstacks-for-API-errors.md
+8-11
Original file line number
Diff line number
Diff line change
@@ -57,16 +57,14 @@ class ErrorContent e where
57
57
Andthen, we could define our extended `Error` as:
58
58
59
59
```haskell
60
-
dataContentwhere
61
-
Content::ErrorContente=>e->Content
60
+
dataContent=foralle.ErrorContente=>Contente
62
61
63
62
classErrorewhere
64
63
getErrorContent::e->Content
65
64
getErrorCallStack::e->CallStack
66
65
```
67
66
68
-
We need a `Content` wrapper as a `GADT`, to prevent the typeof the `ErrorContent` from propagating to the typeof `Error`, while ensuring that it is indeed an `ErrorContent`.
69
-
67
+
We need `e`in `Content` wrapper to be an existential type, to prevent the typeof the `ErrorContent` from propagating to the typeof `Error`, while ensuring that it is indeed an `ErrorContent`.
70
68
If we do this, we could define two generic functions for every `Error e`.
71
69
72
70
One to print the original error, without a stack-trace:
@@ -137,8 +135,7 @@ class Error e where
137
135
Where `Cause` is another wrapper like `Content`:
138
136
139
137
```haskell
140
-
dataCausewhere
141
-
Cause::Errorc=>c->Cause
138
+
dataCause=forallc.Errorc=>Causec
142
139
```
143
140
144
141
And that would allow us to define `prettyError` as follows:
@@ -172,15 +169,15 @@ But, other than that, it comes down to adding a space for the stack-trace in the
172
169
173
170
At least, we can have a reusable wrapper for errors (that must now implement the `ErrorContent` class).
174
171
175
-
So we can define an `ErrorWithStack` data type using a `GADT` as follows:
0 commit comments