Skip to content

Commit 5582a19

Browse files
committed
Clarify motivation for unifying stacktrace printing
1 parent 7edd91a commit 5582a19

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

docs/ADR-10-Callstacks-for-API-errors.md

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,17 +41,20 @@ class Error e where
4141
getErrorCallStack :: e -> CallStack
4242
```
4343

44-
We could leave it there but, ideally, we would like every error to include the stack-trace when pretty printing it.
45-
So we can do it once, by separating the actual error from our extended `Error` type.
44+
We could leave it there but, we don't want each error to manually print their own stack-trace as part of their implementation of `prettyError`, we would rather implement that functionality once and for all.
45+
We want different errors to customize their own error message, but we expect the overall template of `error message + stack-trace` to be presented in the same consistent way.
46+
Also, we want to be able to print the error descriptions without stack-trace if necessary.
47+
48+
We can achieve both things by separating the actual error from our extended `Error` type.
4649
So we can rename the old `Error` as `ErrorContent`.
47-
Which could be a class just like this:
50+
Which would leave us with a class just like this:
4851

4952
```haskell
5053
class ErrorContent e where
5154
prettyErrorContent :: e -> Doc ann
5255
```
5356

54-
And then we could define our extended `Error` as:
57+
And then, we could define our extended `Error` as:
5558

5659
```haskell
5760
data Content where

0 commit comments

Comments
 (0)