mirror of
https://github.com/fluencelabs/wasm-bindgen
synced 2025-06-14 21:41:23 +00:00
Switch from failure
to anyhow
(#1851)
This commit switches all of `wasm-bindgen` from the `failure` crate to `anyhow`. The `anyhow` crate should serve all the purposes that we previously used `failure` for but has a few advantages: * It's based on the standard `Error` trait rather than a custom `Fail` trait, improving ecosystem compatibility. * We don't need a `#[derive(Fail)]`, which means that's less code to compile for `wasm-bindgen`. This notably helps the compile time of `web-sys` itself. * Using `Result<()>` in `fn main` with `anyhow::Error` produces human-readable output, so we can use that natively.
This commit is contained in:
@ -8,7 +8,7 @@ use crate::js::incoming;
|
||||
use crate::js::outgoing;
|
||||
use crate::js::Context;
|
||||
use crate::webidl::Binding;
|
||||
use failure::{bail, Error};
|
||||
use anyhow::{bail, Error};
|
||||
use std::collections::HashSet;
|
||||
use wasm_webidl_bindings::ast;
|
||||
|
||||
|
@ -8,7 +8,7 @@ use crate::descriptor::VectorKind;
|
||||
use crate::js::binding::JsBuilder;
|
||||
use crate::js::Context;
|
||||
use crate::webidl::NonstandardIncoming;
|
||||
use failure::{bail, Error};
|
||||
use anyhow::{bail, Error};
|
||||
use wasm_webidl_bindings::ast;
|
||||
|
||||
pub struct Incoming<'a, 'b> {
|
||||
|
@ -5,7 +5,7 @@ use crate::webidl::{AuxEnum, AuxExport, AuxExportKind, AuxImport, AuxStruct};
|
||||
use crate::webidl::{AuxValue, Binding};
|
||||
use crate::webidl::{JsImport, JsImportName, NonstandardWebidlSection, WasmBindgenAux};
|
||||
use crate::{Bindgen, EncodeInto, OutputMode};
|
||||
use failure::{bail, Error, ResultExt};
|
||||
use anyhow::{bail, Context as _, Error};
|
||||
use std::collections::{BTreeMap, BTreeSet, HashMap, HashSet};
|
||||
use std::fs;
|
||||
use std::path::{Path, PathBuf};
|
||||
@ -1888,7 +1888,7 @@ impl<'a> Context<'a> {
|
||||
check_duplicated_getter_and_setter_names(&pairs)?;
|
||||
for (id, export) in pairs {
|
||||
self.generate_export(*id, export, bindings)
|
||||
.with_context(|_| {
|
||||
.with_context(|| {
|
||||
format!(
|
||||
"failed to generate bindings for Rust export `{}`",
|
||||
export.debug_name,
|
||||
@ -1901,7 +1901,7 @@ impl<'a> Context<'a> {
|
||||
let catch = aux.imports_with_catch.contains(&id);
|
||||
let assert_no_shim = aux.imports_with_assert_no_shim.contains(&id);
|
||||
self.generate_import(*id, import, bindings, variadic, catch, assert_no_shim)
|
||||
.with_context(|_| {
|
||||
.with_context(|| {
|
||||
format!("failed to generate bindings for import `{:?}`", import,)
|
||||
})?;
|
||||
}
|
||||
|
@ -6,7 +6,7 @@ use crate::descriptor::VectorKind;
|
||||
use crate::js::binding::JsBuilder;
|
||||
use crate::js::Context;
|
||||
use crate::webidl::NonstandardOutgoing;
|
||||
use failure::{bail, Error};
|
||||
use anyhow::{bail, Error};
|
||||
use wasm_webidl_bindings::ast;
|
||||
|
||||
pub struct Outgoing<'a, 'b> {
|
||||
|
Reference in New Issue
Block a user