Error handling during AST transform
#3409
Unanswered
ShayRubach
asked this question in
Q&A
Replies: 2 comments
-
I'm planning to do something like this for analytics. Seems like creating a shared BTreeMap (or whatever data structure you need) with Lazy Static or Once Cell should work. |
Beta Was this translation helpful? Give feedback.
0 replies
-
use once_cell::sync::Lazy;
use std::collections::BTreeSet;
use std::sync::Mutex;
static ERR_SET: Lazy<Mutex<BTreeSet<String>>> = Lazy::new(|| Mutex::new(BTreeSet::new()));
fn insert_err(err: &str) {
ERR_SET.lock().unwrap().insert(err.to_string();
} Slightly simplified from my code to collect function names. You'll probably want something better than the I was delighted at how good the Once Cell documentation and API are. |
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
Uh oh!
There was an error while loading. Please reload this page.
-
I would like to return some errors in my code which implements some
visit_mut
s. I know I know, they do not return anything, but I would like to append errors along the way (during transformation) and return them back to the client who called thetransform
ation.I examined the
Handler
but I didn't quite figure out what do I do with it. Is that the direction to take? Or, alternatively are there any other solutions to it as far as you know?Thanks! 🙇♂️
Beta Was this translation helpful? Give feedback.
All reactions