Page MenuHomePhabricator

[Chronik] Add `abc-rust-error` crate for convenient error handling
ClosedPublic

Authored by tobias_ruck on Jul 20 2022, 10:20.

Details

Summary

Add abc-rust-error: helpers and re-exports for error handling.

If RUST_BACKTRACE is enabled, Reports from eyre using stable-eyre will give us a detailled backtrace to where an error
originated.

Depends on D11795.

Test Plan

ninja check-crates

Diff Detail

Repository
rABC Bitcoin ABC
Branch
chronik-error
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 19675
Build 39069: Build Diffbuild-chronik
Build 39068: arc lint + arc unit

Event Timeline

Tail of the build log:

     Running tests/test_error.rs (abc-ci-builds/build-chronik/chronik/cargo/build/debug/deps/test_error-fc98e188e866a6fc)

running 1 test
test test_error ... ok

test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s

   Doc-tests bitcoinsuite-core

running 17 tests
test src/hash.rs - hash::Hashed::SIZE (line 47) ... ok
test src/hash.rs - hash::Hashed::hex_be (line 160) ... ok
test src/hash.rs - hash::Hashed::from_be_slice (line 234) ... ok
test src/hash.rs - hash::Hashed::Array (line 60) ... ok
test src/block/block_hash.rs - block::block_hash::BlockHash::to_bytes (line 28) ... ok
test src/block/block_hash.rs - block::block_hash::BlockHash::to_vec (line 43) ... ok
test src/hash.rs - hash::Hashed::from_le_bytes (line 73) ... ok
test src/hash.rs - hash::Hashed::from_be_hex (line 288) ... ok
test src/hash.rs - hash::Hashed::as_le_bytes (line 83) ... ok
test src/hash.rs - hash::Hashed::from_be_bytes (line 93) ... ok
test src/hash.rs - hash::Hashed::from_le_hex (line 259) ... ok
test src/hash.rs - hash::Hashed::from_le_slice (line 212) ... ok
test src/hash.rs - hash::Hashed::to_be_bytes (line 120) ... ok
test src/hash.rs - hash::Hashed::hex_le (line 138) ... ok
test src/hash.rs - hash::Hashed::to_le_bytes (line 108) ... ok
test src/hash.rs - hash::Hashed::to_le_vec (line 178) ... ok
test src/hash.rs - hash::Hashed::to_be_vec (line 195) ... ok

test result: ok. 17 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.68s

   Doc-tests bitcoinsuite-error

running 0 tests

test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s

[4/4] cd /work && /usr/bin/cmake -E env CARGO_TARGET_DIR="/work/abc-ci-builds/build-chronik/chronik/cargo/build" CARGO_BUILD_RUSTC="/root/.rustup/toolchains/1.61.0-x86_64-unknown-linux-gnu/bin/rustc" CARGO_BUILD_RUSTDOC="/root/.rustup/toolchains/1.61.0-x86_64-unknown-linux-gnu/bin/rustdoc" /root/.rustup/toolchains/1.61.0-x86_64-unknown-linux-gnu/bin/cargo clippy --package bitcoinsuite-* -- -D warnings
    Blocking waiting for file lock on package cache
    Blocking waiting for file lock on build directory
    Checking gimli v0.26.1
    Checking adler v1.0.2
    Checking rustc-demangle v0.1.21
    Checking once_cell v1.13.0
    Checking cfg-if v1.0.0
    Checking indenter v0.3.3
    Checking hex v0.4.3
    Checking memchr v2.5.0
    Checking libc v0.2.126
    Checking thiserror v1.0.31
    Checking miniz_oxide v0.5.3
    Checking eyre v0.6.8
    Checking bitcoinsuite-core v0.1.0 (/work/chronik/bitcoinsuite-core)
    Checking object v0.28.4
    Checking addr2line v0.17.0
    Checking backtrace v0.3.65
    Checking stable-eyre v0.2.2
    Checking bitcoinsuite-error v0.1.0 (/work/chronik/bitcoinsuite-error)
    Finished dev [unoptimized + debuginfo] target(s) in 7.79s
ninja: build stopped: cannot make progress due to previous errors.
Build build-chronik failed with exit code 1

Removed builds of not-yet-existent chronik-* packages

chronik/bitcoinsuite-error/src/lib.rs
27

Is it possible to move this into a separate file and avoid having to maintain it in all the lib.rs files ?

We discussed offline the possibility to move the linter config to another file, but it's not clear if this is possible. In any case this can be done in another diff.

This revision is now accepted and ready to land.Jul 21 2022, 20:33

Update to abc-rust- naming convention

tobias_ruck retitled this revision from [Chronik] Add `bitcoinsuite-error` to [Chronik] Add `abc-rust-error` crate for convenient error handling.Jul 22 2022, 15:17
tobias_ruck edited the summary of this revision. (Show Details)
tobias_ruck edited the test plan for this revision. (Show Details)