rust-gamedig/.pre-commit-config.yaml
Tom 5e7e010d24
[Crate] Add rich error type (#80)
* Add rich error type with source and backtrace

Adds a rich error type that will take a backtrace and allow capturing
the source of the error. The best way to use this is with the included
helpers that will automatically capture the backtrace and convert the
source error:

```
GDRichError::packet_bad_from_into("Reason packet was bad")
```

* [Crate] Bump MSRV to 1.65.0

This is required for backtraces in rich errors.

* Remove leftover debug logging

* [Errors] Replace variant overloads with single .rich method on kind enum

This overhaul replaces the exhaustive impls of each variant as multiple
methods on the rich error type with a singular .rich() method on the
kind enum. This consumes the variant and converts it to a rich error
with a source (.into() can be used if a source is not needed).

I also took the liberty of replacing all usages with the this new method
as I saw fit (adding various error messages) and converting a few
PacketBad errors to TypeParse errors when they are the result of parse
failing.

* Fix problem with rustdoc

* Remove BadGame's owned string

* Rename GDError to GDErrorKind

* Rename GDRichError to GDError

* Remove error impl from GDErrorKind

* Fix tests not passing

* Use error context everywhere map_err is used

* Improve GDError display formatter

* Add tests for new error type
2023-08-05 12:36:48 +03:00

53 lines
1.6 KiB
YAML

# See https://pre-commit.com for more information
# See https://pre-commit.com/hooks.html for more hooks
repos:
- repo: local
hooks:
- id: clippy
name: Check clippy
language: system
files: '[.]rs$'
pass_filenames: false
entry: rustup run --install nightly-2023-07-09 cargo-clippy -- -- -D warnings
- id: build-no-features
name: Check crate build with no features
language: system
files: '[.]rs$'
pass_filenames: false
entry: cargo build --no-default-features
- id: build-all-features
name: Check crate builds with all features
language: system
files: '[.]rs$'
pass_filenames: false
entry: cargo build --all-features --lib --bins --examples
- id: test
name: Check tests pass
language: system
files: '[.]rs$'
pass_filenames: false
entry: cargo test
- id: format
name: Check rustfmt
language: system
files: '[.]rs$'
pass_filenames: false
entry: rustup run --install nightly-2023-07-09 cargo-fmt --check
- id: msrv
name: Check MSRV compiles
language: system
files: '[.]rs$'
pass_filenames: false
entry: rustup run --install 1.65 cargo build
- id: docs
name: Check rustdoc compiles
language: system
files: '[.]rs$'
pass_filenames: false
entry: env RUSTDOCFLAGS="-D warnings" cargo doc
- id: actions
name: Check actions work
language: system
files: '^[.]github/workflows/'
pass_filenames: false
entry: act -q