-
Hello! I'm writing a small interpreter for a DSL, and would like to use miette for error reporting, I've tried defining an error type like this:
But calling I know I could wrap the source in an |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments
-
You can "delay" passing the source code in (and thus make it temporary) by using |
Beta Was this translation helpful? Give feedback.
-
But that still requires the source code to be |
Beta Was this translation helpful? Give feedback.
-
I would also like some assistance with this. I'm running into basically the same issue. I can just clone it, but since I was counting on my error type to extremely light weight. I'm using it as the error side of a parser combinator and so returning the error side is common. I've noticed a massive slow down when I tried to integrate source code reporting to my error reporting. |
Beta Was this translation helpful? Give feedback.
-
In the end I've used a wrapper type that implements It's just a lot of boilerplate: https://gist.github.com/MattX/e6e01b453aad4778947e54a58c6f5be5 |
Beta Was this translation helpful? Give feedback.
In the end I've used a wrapper type that implements
Diagnostic
and delegates every method to a wrappedDiagnostic
, exceptsource_code()
, which it gets from another field. Near the top-level of my code, I wrap the error with this type and bubble that up instead.It's just a lot of boilerplate: https://gist.github.com/MattX/e6e01b453aad4778947e54a58c6f5be5