packing errors also

This commit is contained in:
NikVolf
2018-03-27 17:11:00 +03:00
parent a1bc379d12
commit abc9818925
3 changed files with 27 additions and 3 deletions
+16 -1
View File
@@ -1,3 +1,4 @@
use std::fmt;
use parity_wasm::elements::{
self, Section, Opcode, DataSegment, InitExpr, Internal, External,
ImportCountType,
@@ -19,10 +20,24 @@ pub enum Error {
InvalidCreateSignature,
NoCreateSymbol,
InvalidCreateMember,
NoRetImported,
NoImportSection,
}
impl fmt::Display for Error {
fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> {
match *self {
Error::MalformedModule => write!(f, "Module internal references are inconsistent"),
Error::NoTypeSection => write!(f, "No type section in the module"),
Error::NoExportSection => write!(f, "No export section in the module"),
Error::NoCodeSection => write!(f, "No code section inthe module"),
Error::InvalidCreateSignature => write!(f, "Exported symbol `deploy` has invalid signature, should be () -> ()"),
Error::InvalidCreateMember => write!(f, "Exported symbol `deploy` should be a function"),
Error::NoCreateSymbol => write!(f, "No exported `deploy` symbol"),
Error::NoImportSection => write!(f, "No import section in the module"),
}
}
}
/// If module has an exported "_create" function we want to pack it into "constructor".
/// `raw_module` is the actual contract code
/// `ctor_module` is the constructor which should return `raw_module`