Writing diagnostics into a sink (ie a Vec) #54
cormacrelf
started this conversation in
Show and tell
Replies: 2 comments 1 reply
-
This is really cool! I definitely wanted something like this as part of |
Beta Was this translation helpful? Give feedback.
1 reply
-
fyi, [email protected] has a |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I wrote a little proof of concept to show writing Diagnostics into a sink for later use instead of a TTY.
https://github.com/cormacrelf/miette-sink/blob/master/examples/interactive.rs
It is an attempt to deal with two problems at the same time:
IMO, it doesn't do this very well, because there's too muchnow that we've mergedBox<dyn Diagnostic + 'static>
for that to be a great fit. I think I'll redo this with a concrete generic type required,transparent
and alsoforward
and it's easier to make enums that wrap other Diagnostic-implementing types. (Edit: done)return Err(e)
, i.e. continue on after printing the warning and return an Ok. The method is very similar toIntoDiagnostic
(it is a Result extension trait that looks like.report(sink)?
), but the error type it produces is aReported<D>
withD: Reportable
. That way you can control which errors and which diagnostic types are allowed to be reported in this fashion. If you put all your warnings in one enum and all your errors in another, then you get type-safe control over which diagnostics get "thrown" and which allow you to continue on.It's not super polished at all, but there are some alright ideas here I think.
Beta Was this translation helpful? Give feedback.
All reactions