Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/boydjohnson/tide-errors
https://github.com/boydjohnson/tide-errors
Last synced: 11 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/boydjohnson/tide-errors
- Owner: boydjohnson
- Created: 2021-07-02T03:43:55.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2021-07-03T16:02:38.000Z (over 3 years ago)
- Last Synced: 2024-04-03T01:52:56.530Z (8 months ago)
- Language: Rust
- Size: 9.77 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# tide-errors
If `preroll` errors are too prescriptive for you, but you don't want to write boilerplate to convert errors into JSON errors.Convert `Result` into `Result, E2>` where `Message: Into>`
Bring your own JSON Error type, or use the default error message.
## Example
Use the default JSON errors.
```rust
convert!(db::create_some_object(...).await, ok => Message::created, DatabaseConstraintConversion::<(), UniqueConstraint>::default(), DatabaseConstraintConversion::<(), ForeignKeyConstraint>::default())
```Use your own JSON error
```rust
let options = MyOptions::new(...);convert!(db::create_some_object(...).await, ok => Message::created, DatabaseConstraintConversion::<_, UniqueConstraint>::with_options(options.clone()), DatabaseConstraintConversion::<_, ForeignKeyConstraint>::with_options(options))
```