Skip to content

Commit

Permalink
adjust the README
Browse files Browse the repository at this point in the history
inheritance is broken! forgot to actually test it with my changes.
  • Loading branch information
NCPlayz committed Mar 7, 2021
1 parent 9fb18cf commit 94288d6
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,28 @@ An easy way to define Python exceptions.
use pyexc::PythonException;

#[derive(PythonException)]
pub enum MyExceptions {
pub enum MyBaseException {
#[base(module = "errors")]
#[format("Hello")]
Foo,
Base,
#[format("World")]
Bar,
#[format("!")]
Baz,
}

// Inheritance is experimental!

#[derive(PythonException)]
pub enum MySubExceptions {
#[base(module = "other_errors", inherits = "MyExceptions.Foo")]
pub enum MySubException {
#[base(module = "other_errors", inherits = "errors.MyBaseException")]
#[format("Error!")]
FooFoo,
BaseBase,
#[format("SEGFAULT")]
FooBar,
#[format("Fatal!")]
FooBaz,
}
```

Allows usage in ``Result``, as well as providing a generally Rust-like interface for Python exceptions.

0 comments on commit 94288d6

Please sign in to comment.