Skip to content
This repository has been archived by the owner on Oct 21, 2022. It is now read-only.

Custom user errors #80

Merged
merged 4 commits into from
Aug 1, 2017
Merged

Custom user errors #80

merged 4 commits into from
Aug 1, 2017

Conversation

svyatonik
Copy link
Contributor

closes #20

Most significant API changes:

  1. most of interpreter structs are now generic over user error type
  2. there is default dummy user error type - DummyCustorError (empty struct) && aliases for most used client API types - DefaultProgramInstance = ProgramInstance, DefaultModuleInstance, DefaultModuleInstanceInterface
  3. every custom user error type msut implement CustomUserError trait which is currently just : ::std::fmt::Display + ::std::fmt::Debug + Clone + PartialEq

Most of changes are just cosmetic (propagating generic parameter). Example is in native_custom_error

@@ -1,8 +1,12 @@
//! WebAssembly interpreter module.

/// Interpreter error.
/// Custom user error.
pub trait CustomUserError: 'static + ::std::fmt::Display + ::std::fmt::Debug + Clone + PartialEq {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe call it UserError?

I'm worried about a lot entries in public api are named as SomethingSomethingThing

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

renamed

}
}
}

/// Dummy user error.
#[derive(Debug, Clone, PartialEq)]
pub struct DummyCustomUserError;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe call it just Dummy and refer as error::Dummy everywhere

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So you're suggesting to add additional namespace (error) and move this struct over there (maybe I got it wrong)? Looks like additional headache for me, but if you feel this is ok - please insist.
For now I have renamed it to DummyUserError && added alias DummyError for Error<DummyUserError>. Unfortunately, because of this issue: rust-lang/rust#26264 you still need to import both Error && DummyError, if you want to access Error variants

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah ok, it's ok with just rename

@NikVolf NikVolf merged commit 8f1e83e into master Aug 1, 2017
@NikVolf NikVolf deleted the custom_errors branch August 1, 2017 13:38
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

User traps in user functions
2 participants