Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add error-chain throughout the codebase #361

Merged
merged 9 commits into from
Jun 26, 2017

Conversation

Michael-F-Bryan
Copy link
Contributor

To help with #14 (better error messages), I've included error-chain as a dependency and updated almost all the places we return a Result to use the new error type instead of Box<Error> or std::io::Error.

I skipped the handlebars helpers though. Handlebars expects you to return a specific error type, so you can't use the error-chain error type there.

Now we just need to let people know to use the new error type when returning a Result, and that they should use chain_err() to return an error while also attaching a human-readable explanation of what went wrong.

@Michael-F-Bryan
Copy link
Contributor Author

Travis just errored on the x86_64-unknown-linux-musl build with a rather interesting error message. Apparently while trying to compile backtrace-sys (a dependency of error-chain) the build script failed with:

configure: error: in `/home/travis/build/azerupi/mdBook/target/x86_64-unknown-linux-musl/debug/build/backtrace-sys-204dc57c91e9a514/out':
configure: error: C compiler cannot create executables

This may be an issue in the environment travis uses because it happened on stable, beta, and nightly for just that platform. For now I'll see if excluding the backtrace feature for that target platform works.

On `x86_64-unknown-linux-musl` it looks like travis can't compile
the `backtrace-sys` crate because the `./configure` step fails.

The error message `./configure` gives is:

configure: error: in `/home/travis/build/azerupi/mdBook/target/x86_64-unknown-linux-musl/debug/build/backtrace-sys-204dc57c91e9a514/out':
configure: error: C compiler cannot create executables
@Michael-F-Bryan
Copy link
Contributor Author

Yay, travis is passing again :)

@azerupi and @budziq, I had to add a couple things to the x86_64-unknown-linux-musl build rules in travis.yml to get this to work. error-chain depends on backtrace-sys and on the default travis image you can't compile C libraries using musl. I had to add the following to travis.yml for all x86_64-unknown-linux-musl targets so backtrace-sys will build properly.

dist: trusty
addons:
  apt:
    packages: &musl_packages
      - musl
      - musl-dev
      - musl-tools

@azerupi azerupi merged commit c9a117c into rust-lang:master Jun 26, 2017
@azerupi
Copy link
Contributor

azerupi commented Jun 26, 2017

Thanks! Looks good :)

@Michael-F-Bryan Michael-F-Bryan deleted the error-chain branch June 27, 2017 11:19

errors {
Subprocess(message: String, output: ::std::process::Output) {
description("A subprocess failed")
Copy link
Contributor

@messense messense Jun 28, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This caused mdbook test only print the lines below on failure with no detail

[*]: Testing file: "/Users/messense/Projects/PyO3/guide/src/./conversions.md"
An error occured:
A subprocess failed

Ruin0x11 pushed a commit to Ruin0x11/mdBook that referenced this pull request Aug 30, 2020
Add error-chain throughout the codebase
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants