1
0
mirror of https://github.com/fluencelabs/wasmer synced 2025-03-31 23:11:04 +00:00
1117: Improve formatting of error messages we display from wabt r=MarkMcCaskey a=MarkMcCaskey

Resolves  

Co-authored-by: Mark McCaskey <mark@wasmer.io>
This commit is contained in:
bors[bot] 2020-01-06 20:38:28 +00:00 committed by GitHub
commit 9cf97aa02b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 46 additions and 5 deletions

32
Cargo.lock generated

@ -558,7 +558,7 @@ dependencies = [
"libc", "libc",
"llvm-sys", "llvm-sys",
"once_cell", "once_cell",
"parking_lot", "parking_lot 0.10.0",
"regex", "regex",
] ]
@ -827,6 +827,17 @@ dependencies = [
"md5", "md5",
] ]
[[package]]
name = "parking_lot"
version = "0.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f842b1982eb6c2fe34036a4fbfb06dd185a3f5c8edfaacdf7d1ea10b07de6252"
dependencies = [
"lock_api",
"parking_lot_core 0.6.2",
"rustc_version",
]
[[package]] [[package]]
name = "parking_lot" name = "parking_lot"
version = "0.10.0" version = "0.10.0"
@ -834,7 +845,22 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "92e98c49ab0b7ce5b222f2cc9193fc4efe11c6d0bd4f648e374684a6857b1cfc" checksum = "92e98c49ab0b7ce5b222f2cc9193fc4efe11c6d0bd4f648e374684a6857b1cfc"
dependencies = [ dependencies = [
"lock_api", "lock_api",
"parking_lot_core", "parking_lot_core 0.7.0",
]
[[package]]
name = "parking_lot_core"
version = "0.6.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b876b1b9e7ac6e1a74a6da34d25c42e17e8862aa409cbbbdcfc8d86c6f3bc62b"
dependencies = [
"cfg-if",
"cloudabi",
"libc",
"redox_syscall",
"rustc_version",
"smallvec 0.6.13",
"winapi",
] ]
[[package]] [[package]]
@ -1761,7 +1787,7 @@ dependencies = [
"libc", "libc",
"nix", "nix",
"page_size", "page_size",
"parking_lot", "parking_lot 0.9.0",
"rustc_version", "rustc_version",
"serde", "serde",
"serde-bench", "serde-bench",

@ -11,6 +11,7 @@ extern crate structopt;
use std::collections::HashMap; use std::collections::HashMap;
use std::env; use std::env;
use std::error::Error;
use std::fs::{metadata, read_to_string, File}; use std::fs::{metadata, read_to_string, File};
use std::io; use std::io;
use std::io::Read; use std::io::Read;
@ -623,8 +624,22 @@ fn execute_wasm(options: &Run) -> Result<(), String> {
if !utils::is_wasm_binary(&wasm_binary) { if !utils::is_wasm_binary(&wasm_binary) {
let features = options.features.into_wabt_features(); let features = options.features.into_wabt_features();
wasm_binary = wabt::wat2wasm_with_features(wasm_binary, features) wasm_binary = wabt::wat2wasm_with_features(wasm_binary, features).map_err(|e| {
.map_err(|e| format!("Can't convert from wast to wasm: {:?}", e))?; format!(
"Can't convert from wast to wasm because \"{}\"{}",
e.description(),
match e.kind() {
wabt::ErrorKind::Deserialize(s)
| wabt::ErrorKind::Parse(s)
| wabt::ErrorKind::ResolveNames(s)
| wabt::ErrorKind::Validate(s) => format!(":\n\n{}", s),
wabt::ErrorKind::Nul
| wabt::ErrorKind::WriteText
| wabt::ErrorKind::NonUtf8Result
| wabt::ErrorKind::WriteBinary => "".to_string(),
}
)
})?;
} }
let compiler: Box<dyn Compiler> = get_compiler_by_backend(options.backend, options) let compiler: Box<dyn Compiler> = get_compiler_by_backend(options.backend, options)