Coder Social home page Coder Social logo

shippai's Introduction

Shippai

failure in other languages

Travis PyPI Crates.io

Shippai is a set of libraries that help you with handling failure-style errors from other languages

Right now this project consists of:

  • A Rust library to generate FFI code for your Fail types.

  • A Python library to:

    1. generate exception types from the information provided by that FFI
    2. convert errors passed through that interface into a corresponding exception and raise them together with a complete stacktrace

Examples

Check out the Python example for a rough idea of how it all plays together. Here is how a stacktrace looks like:

$ make install-dev
$ RUST_BACKTRACE=1 python
Python 3.6.5 (default, May 11 2018, 04:00:52)
[GCC 8.1.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import shippai_example
>>> shippai_example.authenticate('', '')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/untitaker/projects/shippai/examples/python/shippai_example/__init__.py", line 25, in authenticate
    errors.check_exception(err[0])
  File "/home/untitaker/projects/shippai/python/shippai/__init__.py", line 144, in check_exception
    _raise_with_more_frames(exc, frames)
  File "/home/untitaker/projects/shippai/python/shippai/__init__.py", line 262, in _raise_with_more_frames
    _append_frame(exc_info, frames[-1])
  File "/home/untitaker/projects/shippai/python/shippai/__init__.py", line 296, in _append_frame
    exec(code, ns)
  File "/home/untitaker/projects/shippai/examples/python/rust/src/lib.rs", line 43, in authenticate
    let res = authenticate_impl(
  File "/home/untitaker/projects/shippai/examples/python/rust/src/lib.rs", line 27, in shippai_example::authenticate_impl::he2a2e071e069a869
    return Err(MyError::UserWrong.into());
  File "/checkout/src/libcore/convert.rs", line 396, in <T as core::convert::Into<U>>::into::hda623f1239c06654
shippai.UserWrong: Invalid username
>>> 

Caveats

Shippai is a work-in-progress, a lot of features are missing. (check the issue tracker)

I also have no idea what I am doing. If you see funny code here (particularly in the FFI parts), don't assume it is because of a good reason. Tell me where I am wrong.

License

Shippai is licensed under MIT, see LICENSE.

shippai's People

Contributors

untitaker avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

shippai's Issues

Ability to transfer raw Fails without Error wrapper

@jan-auer briefly mentioned this during RustFest: Their rust FFI returns Fails instead of Errors.

  • Determine whether it's generally good enough for everybody to just wrap that into an Error, even if that makes for an ugly C FFI.
  • What are we supposed to do with the ShippaiError type?
  • Or implement custom handling for arbitrary Fails

Filepaths for rust stackframes are broken

As can be seen in the README, the filepaths for rust files are relative, therefore the source code excerpt is missing. Prefixing rust/ to each of them would fix it.

Open questions:

  • Should we provide an option to set the rust source basepath? (easiest solution)
  • Can we figure this out ourselves? (Accessing CARGO_* envvars in rust macro)
  • How does it work with frames from third-party crates?

Should shippai clean up the backtrace?

Rust backtraces typically contain a lot of garbage frames from internals. I wonder if shippai should attempt to remove them, and if so, if we need a blacklist or if there is a simple rule to weed those out.

Explore alternative ways of generating metadata

Currently we have a few problems:

  1. Exporting metadata through the .h file is nice (because it uses existing setup) but quite a hack.
  2. Keeping Python "client" library and Rust "server" library in sync is rather hard until shippai hits 1.0 -- you can pin the version in Cargo, but not really in Python
  3. Python dependencies still have high cost

Ideas:

  • re 1 + 3: Generate Python wrapper from Rust code, let user check in Python wrapper
  • re 2: Just stabilize shippai to 1.0 and never change a thing ever

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.