pub struct Handler {
inner: Rc<RefCell<HandlerInner>>,
}
Expand description
A handler deals with errors and other compiler output.
Fields§
§inner: Rc<RefCell<HandlerInner>>
Implementations§
Source§impl Handler
impl Handler
Sourcepub fn new<T: 'static + Emitter>(emitter: T) -> Self
pub fn new<T: 'static + Emitter>(emitter: T) -> Self
Construct a Handler
using the given emitter
.
Sourcepub fn new_with_buf() -> (Self, BufferEmitter)
pub fn new_with_buf() -> (Self, BufferEmitter)
Construct a Handler
that will append to buf
.
Sourcepub fn with<T>(
logic: impl for<'a> FnOnce(&'a Handler) -> Result<T, LeoError>,
) -> Result<T, ErrBuffer>
pub fn with<T>( logic: impl for<'a> FnOnce(&'a Handler) -> Result<T, LeoError>, ) -> Result<T, ErrBuffer>
Runs logic
provided a handler that collects all errors into the String
,
or if there were none, returns some T
.
Sourcefn last_emitted_err_code(&self) -> Option<i32>
fn last_emitted_err_code(&self) -> Option<i32>
Gets the last emitted error’s exit code.
Sourcepub fn emit_warning(&self, warning: LeoWarning)
pub fn emit_warning(&self, warning: LeoWarning)
Emit the error err
.
Sourcepub fn warning_count(&self) -> usize
pub fn warning_count(&self) -> usize
The number of warnings thus far.
Sourcepub fn had_errors(&self) -> bool
pub fn had_errors(&self) -> bool
Did we have any errors thus far?
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Handler
impl !RefUnwindSafe for Handler
impl !Send for Handler
impl !Sync for Handler
impl Unpin for Handler
impl !UnwindSafe for Handler
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more