Fix error handling in sandboxing/contracts modules (#744)

* Fix error handling in sandboxing/contracts modules

* Add some docs.

* Add some tests.

* grammar
This commit is contained in:
Sergey Pepyakin
2018-09-19 11:01:25 +03:00
committed by Gav Wood
parent 400a22ebe5
commit 488830e81a
7 changed files with 154 additions and 21 deletions
+6 -1
View File
@@ -190,7 +190,12 @@ pub struct Instance<T> {
}
impl<T> Instance<T> {
/// Instantiate a module with the given [`EnvironmentDefinitionBuilder`].
/// Instantiate a module with the given [`EnvironmentDefinitionBuilder`]. It will
/// run the `start` function with the given `state`.
///
/// Returns `Err(Error::Module)` if this module can't be instantiated with the given
/// environment. If execution of `start` function generated a trap, then `Err(Error::Execution)` will
/// be returned.
///
/// [`EnvironmentDefinitionBuilder`]: struct.EnvironmentDefinitionBuilder.html
pub fn new(code: &[u8], env_def_builder: &EnvironmentDefinitionBuilder<T>, state: &mut T) -> Result<Instance<T>, Error> {