1use thiserror::Error;
2
3#[derive(Error, Debug)]
4pub enum CompileError {
5 #[error("Encountered unsupported type `{0}`")]
6 UnsupportedType(String),
7 #[error("Encountered unsupported operation `{0}`")]
8 UnsupportedOp(String),
9}
10
11pub type Result<T> = core::result::Result<T, CompileError>;
12
13#[derive(Default)]
17pub struct EmissionErrors(core::cell::RefCell<Vec<CompileError>>);
18
19impl EmissionErrors {
20 pub fn record(&self, error: CompileError) {
22 self.0.borrow_mut().push(error);
23 }
24
25 pub fn take(&self) -> Vec<CompileError> {
27 core::mem::take(&mut self.0.borrow_mut())
28 }
29}