pax_global_header00006660000000000000000000000064147020144520014511gustar00rootroot0000000000000052 comment=0b22d4dac6c84dc8db4e0d6825ab3951f27a0bb6 human-panic-2.0.2/000077500000000000000000000000001470201445200137125ustar00rootroot00000000000000human-panic-2.0.2/.clippy.toml000066400000000000000000000013651470201445200161720ustar00rootroot00000000000000allow-print-in-tests = true allow-expect-in-tests = true allow-unwrap-in-tests = true allow-dbg-in-tests = true disallowed-methods = [ { path = "std::option::Option::map_or", reason = "prefer `map(..).unwrap_or(..)` for legibility" }, { path = "std::option::Option::map_or_else", reason = "prefer `map(..).unwrap_or_else(..)` for legibility" }, { path = "std::result::Result::map_or", reason = "prefer `map(..).unwrap_or(..)` for legibility" }, { path = "std::result::Result::map_or_else", reason = "prefer `map(..).unwrap_or_else(..)` for legibility" }, { path = "std::iter::Iterator::for_each", reason = "prefer `for` for side-effects" }, { path = "std::iter::Iterator::try_for_each", reason = "prefer `for` for side-effects" }, ] human-panic-2.0.2/.github/000077500000000000000000000000001470201445200152525ustar00rootroot00000000000000human-panic-2.0.2/.github/renovate.json5000066400000000000000000000047141470201445200200630ustar00rootroot00000000000000{ schedule: [ 'before 5am on the first day of the month', ], semanticCommits: 'enabled', commitMessageLowerCase: 'never', configMigration: true, dependencyDashboard: true, customManagers: [ { customType: 'regex', fileMatch: [ '^rust-toolchain\\.toml$', 'Cargo.toml$', 'clippy.toml$', '\\.clippy.toml$', '^\\.github/workflows/ci.yml$', '^\\.github/workflows/rust-next.yml$', ], matchStrings: [ 'STABLE.*?(?\\d+\\.\\d+(\\.\\d+)?)', '(?\\d+\\.\\d+(\\.\\d+)?).*?STABLE', ], depNameTemplate: 'STABLE', packageNameTemplate: 'rust-lang/rust', datasourceTemplate: 'github-releases', }, ], packageRules: [ { commitMessageTopic: 'Rust Stable', matchManagers: [ 'custom.regex', ], matchPackageNames: [ 'STABLE', ], extractVersion: '^(?\\d+\\.\\d+)', // Drop the patch version schedule: [ '* * * * *', ], automerge: true, }, // Goals: // - Keep version reqs low, ignoring compatible normal/build dependencies // - Take advantage of latest dev-dependencies // - Rollup safe upgrades to reduce CI runner load // - Help keep number of versions down by always using latest breaking change // - Have lockfile and manifest in-sync { matchManagers: [ 'cargo', ], matchDepTypes: [ 'build-dependencies', 'dependencies', ], matchCurrentVersion: '>=0.1.0', matchUpdateTypes: [ 'patch', ], enabled: false, }, { matchManagers: [ 'cargo', ], matchDepTypes: [ 'build-dependencies', 'dependencies', ], matchCurrentVersion: '>=1.0.0', matchUpdateTypes: [ 'minor', 'patch', ], enabled: false, }, { matchManagers: [ 'cargo', ], matchDepTypes: [ 'dev-dependencies', ], matchCurrentVersion: '>=0.1.0', matchUpdateTypes: [ 'patch', ], automerge: true, groupName: 'compatible (dev)', }, { matchManagers: [ 'cargo', ], matchDepTypes: [ 'dev-dependencies', ], matchCurrentVersion: '>=1.0.0', matchUpdateTypes: [ 'minor', 'patch', ], automerge: true, groupName: 'compatible (dev)', }, ], } human-panic-2.0.2/.github/settings.yml000066400000000000000000000031361470201445200176400ustar00rootroot00000000000000# These settings are synced to GitHub by https://probot.github.io/apps/settings/ repository: description: "Panic messages for humans." homepage: "https://docs.rs/human-panic" topics: "rust cli panic-hook" has_issues: true has_projects: false has_wiki: false has_downloads: true default_branch: master # Preference: people do clean commits allow_merge_commit: true # Backup in case we need to clean up commits allow_squash_merge: true # Not really needed allow_rebase_merge: false allow_auto_merge: true delete_branch_on_merge: true squash_merge_commit_title: "PR_TITLE" squash_merge_commit_message: "PR_BODY" merge_commit_message: "PR_BODY" labels: # Type - name: bug color: '#b60205' description: "Not as expected" - name: enhancement color: '#1d76db' description: "Improve the expected" # Flavor - name: question color: "#cc317c" description: "Uncertainty is involved" - name: breaking-change color: "#e99695" - name: good first issue color: '#c2e0c6' description: "Help wanted!" # This serves more as documentation. # Branch protection API was replaced by rulesets but settings isn't updated. # See https://github.com/repository-settings/app/issues/825 # # branches: # - name: master # protection: # required_pull_request_reviews: null # required_conversation_resolution: true # required_status_checks: # # Required. Require branches to be up to date before merging. # strict: false # contexts: ["CI", "Spell Check with Typos"] # enforce_admins: false # restrictions: null human-panic-2.0.2/.github/workflows/000077500000000000000000000000001470201445200173075ustar00rootroot00000000000000human-panic-2.0.2/.github/workflows/audit.yml000066400000000000000000000023131470201445200211370ustar00rootroot00000000000000name: Security audit permissions: contents: read on: pull_request: paths: - '**/Cargo.toml' - '**/Cargo.lock' push: branches: - master env: RUST_BACKTRACE: 1 CARGO_TERM_COLOR: always CLICOLOR: 1 concurrency: group: "${{ github.workflow }}-${{ github.ref }}" cancel-in-progress: true jobs: security_audit: permissions: issues: write # to create issues (actions-rs/audit-check) checks: write # to create check (actions-rs/audit-check) runs-on: ubuntu-latest # Prevent sudden announcement of a new advisory from failing ci: continue-on-error: true steps: - name: Checkout repository uses: actions/checkout@v4 - uses: actions-rs/audit-check@v1 with: token: ${{ secrets.GITHUB_TOKEN }} cargo_deny: permissions: issues: write # to create issues (actions-rs/audit-check) checks: write # to create check (actions-rs/audit-check) runs-on: ubuntu-latest strategy: matrix: checks: - bans licenses sources steps: - uses: actions/checkout@v4 - uses: EmbarkStudios/cargo-deny-action@v2 with: command: check ${{ matrix.checks }} rust-version: stable human-panic-2.0.2/.github/workflows/ci.yml000066400000000000000000000120541470201445200204270ustar00rootroot00000000000000name: CI permissions: contents: read on: pull_request: push: branches: - master env: CARGO_TERM_COLOR: always CLICOLOR: 1 concurrency: group: "${{ github.workflow }}-${{ github.ref }}" cancel-in-progress: true jobs: ci: permissions: contents: none name: CI needs: [test, msrv, lockfile, docs, rustfmt, clippy, minimal-versions] runs-on: ubuntu-latest if: "always()" steps: - name: Failed run: exit 1 if: "contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled') || contains(needs.*.result, 'skipped')" test: name: Test strategy: matrix: os: ["ubuntu-latest", "windows-latest", "macos-latest"] rust: ["stable"] continue-on-error: ${{ matrix.rust != 'stable' }} runs-on: ${{ matrix.os }} steps: - name: Checkout repository uses: actions/checkout@v4 - name: Install Rust uses: dtolnay/rust-toolchain@stable with: toolchain: ${{ matrix.rust }} - uses: Swatinem/rust-cache@v2 - uses: taiki-e/install-action@cargo-hack - name: Build run: cargo test --workspace --no-run - name: Test run: cargo hack test --feature-powerset --exclude-features nightly --workspace - name: Test Release run: cargo test --workspace --release msrv: name: "Check MSRV" runs-on: ubuntu-latest steps: - name: Checkout repository uses: actions/checkout@v4 - name: Install Rust uses: dtolnay/rust-toolchain@stable with: toolchain: stable - uses: Swatinem/rust-cache@v2 - uses: taiki-e/install-action@cargo-hack - name: Default features run: cargo hack check --feature-powerset --exclude-features nightly --locked --rust-version --ignore-private --workspace --all-targets minimal-versions: name: Minimal versions runs-on: ubuntu-latest steps: - name: Checkout repository uses: actions/checkout@v4 - name: Install stable Rust uses: dtolnay/rust-toolchain@stable with: toolchain: stable - name: Install nightly Rust uses: dtolnay/rust-toolchain@stable with: toolchain: nightly - name: Downgrade dependencies to minimal versions run: cargo +nightly generate-lockfile -Z minimal-versions - name: Compile with minimal versions run: cargo +stable check --workspace --locked lockfile: runs-on: ubuntu-latest steps: - name: Checkout repository uses: actions/checkout@v4 - name: Install Rust uses: dtolnay/rust-toolchain@stable with: toolchain: stable - uses: Swatinem/rust-cache@v2 - name: "Is lockfile updated?" run: cargo update --workspace --locked docs: name: Docs runs-on: ubuntu-latest steps: - name: Checkout repository uses: actions/checkout@v4 - name: Install Rust uses: dtolnay/rust-toolchain@stable with: toolchain: "1.81.0" # STABLE - uses: Swatinem/rust-cache@v2 - name: Check documentation env: RUSTDOCFLAGS: -D warnings run: cargo doc --workspace --no-deps --document-private-items rustfmt: name: rustfmt runs-on: ubuntu-latest steps: - name: Checkout repository uses: actions/checkout@v4 - name: Install Rust uses: dtolnay/rust-toolchain@stable with: toolchain: "1.81.0" # STABLE components: rustfmt - uses: Swatinem/rust-cache@v2 - name: Check formatting run: cargo fmt --all -- --check clippy: name: clippy runs-on: ubuntu-latest permissions: security-events: write # to upload sarif results steps: - name: Checkout repository uses: actions/checkout@v4 - name: Install Rust uses: dtolnay/rust-toolchain@stable with: toolchain: "1.81.0" # STABLE components: clippy - uses: Swatinem/rust-cache@v2 - name: Install SARIF tools run: cargo install clippy-sarif --locked - name: Install SARIF tools run: cargo install sarif-fmt --locked - name: Check run: > cargo clippy --workspace --all-targets --message-format=json -- -D warnings --allow deprecated | clippy-sarif | tee clippy-results.sarif | sarif-fmt continue-on-error: true - name: Upload uses: github/codeql-action/upload-sarif@v3 with: sarif_file: clippy-results.sarif wait-for-processing: true - name: Report status run: cargo clippy --workspace --all-targets -- -D warnings --allow deprecated coverage: name: Coverage runs-on: ubuntu-latest steps: - name: Checkout repository uses: actions/checkout@v4 - name: Install Rust uses: dtolnay/rust-toolchain@stable with: toolchain: stable - uses: Swatinem/rust-cache@v2 - name: Install cargo-tarpaulin run: cargo install cargo-tarpaulin - name: Gather coverage run: cargo tarpaulin --output-dir coverage --out lcov - name: Publish to Coveralls uses: coverallsapp/github-action@master with: github-token: ${{ secrets.GITHUB_TOKEN }} human-panic-2.0.2/.github/workflows/committed.yml000066400000000000000000000011231470201445200220140ustar00rootroot00000000000000# Not run as part of pre-commit checks because they don't handle sending the correct commit # range to `committed` name: Lint Commits on: [pull_request] permissions: contents: read env: RUST_BACKTRACE: 1 CARGO_TERM_COLOR: always CLICOLOR: 1 concurrency: group: "${{ github.workflow }}-${{ github.ref }}" cancel-in-progress: true jobs: committed: name: Lint Commits runs-on: ubuntu-latest steps: - name: Checkout Actions Repository uses: actions/checkout@v4 with: fetch-depth: 0 - name: Lint Commits uses: crate-ci/committed@master human-panic-2.0.2/.github/workflows/pre-commit.yml000066400000000000000000000007611470201445200221120ustar00rootroot00000000000000name: pre-commit permissions: {} # none on: pull_request: push: branches: [master] env: RUST_BACKTRACE: 1 CARGO_TERM_COLOR: always CLICOLOR: 1 concurrency: group: "${{ github.workflow }}-${{ github.ref }}" cancel-in-progress: true jobs: pre-commit: permissions: contents: read runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - uses: actions/setup-python@v5 with: python-version: '3.x' - uses: pre-commit/action@v3.0.1 human-panic-2.0.2/.github/workflows/rust-next.yml000066400000000000000000000027671470201445200220170ustar00rootroot00000000000000name: rust-next permissions: contents: read on: schedule: - cron: '8 8 8 * *' env: CARGO_TERM_COLOR: always CLICOLOR: 1 concurrency: group: "${{ github.workflow }}-${{ github.ref }}" cancel-in-progress: true jobs: test: name: Test strategy: matrix: os: ["ubuntu-latest", "windows-latest", "macos-latest"] rust: ["stable", "beta"] include: - os: ubuntu-latest rust: "nightly" continue-on-error: ${{ matrix.rust != 'stable' }} runs-on: ${{ matrix.os }} steps: - name: Checkout repository uses: actions/checkout@v4 - name: Install Rust uses: dtolnay/rust-toolchain@stable with: toolchain: ${{ matrix.rust }} - uses: Swatinem/rust-cache@v2 - uses: taiki-e/install-action@cargo-hack - name: Build run: cargo test --workspace --no-run - name: Test run: cargo hack test --feature-powerset --exclude-features nightly --workspace latest: name: "Check latest dependencies" runs-on: ubuntu-latest steps: - name: Checkout repository uses: actions/checkout@v4 - name: Install Rust uses: dtolnay/rust-toolchain@stable with: toolchain: stable - uses: Swatinem/rust-cache@v2 - uses: taiki-e/install-action@cargo-hack - name: Update dependencies run: cargo update - name: Build run: cargo test --workspace --no-run - name: Test run: cargo hack test --feature-powerset --exclude-features nightly --workspace human-panic-2.0.2/.github/workflows/spelling.yml000066400000000000000000000007031470201445200216470ustar00rootroot00000000000000name: Spelling permissions: contents: read on: [pull_request] env: RUST_BACKTRACE: 1 CARGO_TERM_COLOR: always CLICOLOR: 1 concurrency: group: "${{ github.workflow }}-${{ github.ref }}" cancel-in-progress: true jobs: spelling: name: Spell Check with Typos runs-on: ubuntu-latest steps: - name: Checkout Actions Repository uses: actions/checkout@v4 - name: Spell Check Repo uses: crate-ci/typos@master human-panic-2.0.2/.gitignore000066400000000000000000000000071470201445200156770ustar00rootroot00000000000000target human-panic-2.0.2/.pre-commit-config.yaml000066400000000000000000000011511470201445200201710ustar00rootroot00000000000000repos: - repo: https://github.com/pre-commit/pre-commit-hooks rev: v4.5.0 hooks: - id: check-yaml stages: [commit] - id: check-json stages: [commit] - id: check-toml stages: [commit] - id: check-merge-conflict stages: [commit] - id: check-case-conflict stages: [commit] - id: detect-private-key stages: [commit] - repo: https://github.com/crate-ci/typos rev: v1.16.20 hooks: - id: typos stages: [commit] - repo: https://github.com/crate-ci/committed rev: v1.0.20 hooks: - id: committed stages: [commit-msg] human-panic-2.0.2/CHANGELOG.md000066400000000000000000000241111470201445200155220ustar00rootroot00000000000000# Change Log All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/). ## [Unreleased] - ReleaseDate ## [2.0.2] - 2024-10-10 ### Fixes - Improve detection of what can be trimmed from backtrace ## [2.0.1] - 2024-07-25 ### Compatibility - Update MSV to 1.74 ## [2.0.0] - 2024-04-17 ### Compatibility - Update MSV to 1.73 - `PanicStyle` is now non-exhaustive - `Method` is now non-exhaustive - `Metadata`s fields are now private, requiring setters ### Features - Add `Metadata::support` for where to send reports ## [1.2.3] - 2024-01-12 ### Internal - Update anstream ## [1.2.2] - 2023-11-06 ### Performance - Improve build times by only pullin in `toml` rendering, not parsing ## [1.2.1] - 2023-09-28 ### Internal - Update anstream ## [1.2.0] - 2023-08-24 ### Compatibility - Update MSV to 1.70.0 ### Performance - Improve build times by dropping `is-terminal` dependency ## [1.1.5] - 2023-06-13 ### Fixes - Avoid symbol conflicts from macros ## [1.1.4] - 2023-04-13 ### Internal - Dependency update ## [1.1.3] - 2023-03-16 ### Internal - Dependency update ## [1.1.2] - 2023-03-14 ### Compatibility - Update MSRV to 1.64.0 ### Fixes - Correctly handle `CLICOLOR=1` - Correctly handle `NO_COLOR=` - Auto-enable color for CI - Update a macro to use `$crate` ## [1.1.1] - 2023-02-28 ### Internal - Update dependencies ## [1.1.0] - 2023-02-01 ### Features - Expose `metadata!` constructor - Expose `PanicStyle::default()` for knowing which handler to use:: ### Fixes - Detect when color can be used - Make color optional (opt-out) ## [v1.0.3] ### Features - *(nightly)* Include original panic ### Fixes - Use normal panics when `RUST_BACKTRACE` is enabled - Skip unnecessary frames in backtrace ## 2018-04-18, Version 0.3.0 ### Commits - [[`650df0bf4d`](https://github.com/rust-cli/human-panic/commits/650df0bf4de62239e9592b2185ebbd4875640864)] (cargo-release) version 0.3.0 (Yoshua Wuyts) - [[`a3ec0ddb97`](https://github.com/rust-cli/human-panic/commits/a3ec0ddb97eb5940ab56785eb54eed52ead3a82b)] Fixing wrong data in certain crash dump fields (#15) Fixing a bug in the log dumps * Carrying over metadata from first macro call to properly include metadata in crash dumps. * Making Method derive Copy (Katharina) - [[`ed11055e06`](https://github.com/rust-cli/human-panic/commits/ed11055e0602c3c8d223ed8354058fefb9ac47ec)] Merge pull request #16 from killercup/docs Ensure no docs are missing (Pascal Hertleif) - [[`4540d77276`](https://github.com/rust-cli/human-panic/commits/4540d77276eafbfb57c922f57f1aa04cd5cb1cd5)] Fix typos (#14) * Correct typo embarrassing * Fix typos (Andy Slack) - [[`9e972ef654`](https://github.com/rust-cli/human-panic/commits/9e972ef654df70047f73df51befa3ba2bcb2e5c5)] Ensure no docs are missing (Pascal Hertleif) - [[`b82ac5c35a`](https://github.com/rust-cli/human-panic/commits/b82ac5c35a9e5772a54033a084d1cc784ffd6510)] Merge pull request #11 from skade/update-readme Update README with current interfac (Pascal Hertleif) - [[`21c5417580`](https://github.com/rust-cli/human-panic/commits/21c5417580e6bf4cbe330715b5cc4ae39e4f5d8e)] Update README with current interface (Florian Gilcher) - [[`d86232967d`](https://github.com/rust-cli/human-panic/commits/d86232967d3bf9dc868a4cd68bab2e1004b6d2dc)] Merge pull request #10 from killercup/rollup Rollup (Pascal Hertleif) - [[`80046e1488`](https://github.com/rust-cli/human-panic/commits/80046e148860e0bcde3d5a8e9c1a56bf5f32a37c)] Use more generic way to get a Path (Pascal Hertleif) - [[`dc05d332a0`](https://github.com/rust-cli/human-panic/commits/dc05d332a0527812fc239f4622289fb593aac936)] Merge skade-join-properly into rollup (Pascal Hertleif) - [[`2e0127c830`](https://github.com/rust-cli/human-panic/commits/2e0127c8303d7ea5c46e9aacf83e2fa0fdbbbd83)] Merge yoshuawuyts-fix-example into rollup (Pascal Hertleif) - [[`fc16cb8ac2`](https://github.com/rust-cli/human-panic/commits/fc16cb8ac2b692450d689d5650fe82405f35f492)] Update Cargo.lock (Pascal Hertleif) - [[`e53059ff3c`](https://github.com/rust-cli/human-panic/commits/e53059ff3cc5e36bee7dc6e29a6605881122aac3)] rustfmt (Pascal Hertleif) - [[`a51285bb10`](https://github.com/rust-cli/human-panic/commits/a51285bb1044c0ef6e5a8c94f5149549315eef53)] Properly handle file paths using Path and PathBuf (Florian Gilcher) - [[`82ebdccb5a`](https://github.com/rust-cli/human-panic/commits/82ebdccb5a22baf369b12c888af7a0b9cd1d0ee8)] make clippy pass for real this time (Yoshua Wuyts) - [[`2297066f50`](https://github.com/rust-cli/human-panic/commits/2297066f504f98a62c1ddde357aad81a0ed147e4)] please clippy (Yoshua Wuyts) - [[`b1ec2b5b7b`](https://github.com/rust-cli/human-panic/commits/b1ec2b5b7bb5b679ed8287712272f1a7ba3387c8)] fix examples (Yoshua Wuyts) - [[`369ca4e526`](https://github.com/rust-cli/human-panic/commits/369ca4e526b911b8455e1759e7609edf1a606e34)] Bumpding version, adding author (Katharina) - [[`31e1d9ada2`](https://github.com/rust-cli/human-panic/commits/31e1d9ada2b3e0563cac37d32ec952552e129281)] Cleaning up warnings for the big rebase (Katharina Sabel) - [[`3ffa055d57`](https://github.com/rust-cli/human-panic/commits/3ffa055d576c8e572ddcde2744d5aef514b11fa5)] Attempting to fix the `err` example using the failures crate (Katharina Sabel) - [[`5214754bc0`](https://github.com/rust-cli/human-panic/commits/5214754bc093a389a7d44c5fd1e9d6d38df1ea86)] Adding a bit of padding in the log (Katharina Sabel) - [[`031b2b846b`](https://github.com/rust-cli/human-panic/commits/031b2b846b73e6fefa783ffee83c9c5ef6464c3a)] Merging advanced report functionality. (Katharina Sabel) - [[`7a2e923075`](https://github.com/rust-cli/human-panic/commits/7a2e9230751abd3a152d3240a8b4c75891ae8e41)] Merging #4 by yoshuawuyts This commit adds the ability to generate reports based on an application crash. It hooks into the existing panic handler and also exposes the report generation feature via a `pub fn` (Katharina Sabel) - [[`7dc354b88e`](https://github.com/rust-cli/human-panic/commits/7dc354b88e0fc0cfc9f10e6477444f6b73d0afb3)] Preparing for cherrypick (Katharina Sabel) - [[`5002578d8f`](https://github.com/rust-cli/human-panic/commits/5002578d8f5b495d4f37fb68510dd5e5fa624cc6)] Cleaning up merge artefact (Katharina Sabel) - [[`bd4526a315`](https://github.com/rust-cli/human-panic/commits/bd4526a3156aacce08ffce4fbd2339a2bcb2cf84)] Changing the core functionality of the crate Instead of having to wrap around every panic, this now uses `set_hook` once to register the callback to print a pretty status message. This also has the added benefit of pulling in env! calls because the main setup was made into a macro. Optionally the two core functions (print_help and dump_log) can now also be used without the core macro, because they are `pub fn` (Katharina Sabel) - Stable and slim (#1) * Make it compile on stable Also adds a nightly feature flag that will automatically be picked up by docs.rs to build nice docs. * Make clippy a CI-only dependency You can run `cargo clippy` locally to get the same effect. I've also taken the liberty to nail down the rustfmt version to use, so we can update it explicitly. (This is the same CI setup that assert_cli uses.) * Get rid of all dependencies for now Improves compile times :trollface: * Use termcolor for colored output This should make it compatible with windows consoles. * Set up some kind of error handling for the hook * rustfmt * Bump clippy and choose a nightly that actually exists. * Make clippy happy (Pascal Hertleif) - [[`c04ae22d1e`](https://github.com/rust-cli/human-panic/commits/c04ae22d1ef3289d028f9ff5aaefd8a44b5c293c)] update readme output (Yoshua Wuyts) - [[`4a35c860fd`](https://github.com/rust-cli/human-panic/commits/4a35c860fd00835a36184be8068d777d4fa02519)] upgrade desc (Yoshua Wuyts) - [[`ccaf3bce86`](https://github.com/rust-cli/human-panic/commits/ccaf3bce8666879c89ce0222f7f8d1f306bde074)] init (Yoshua Wuyts) - [[`a7135d1e8c`](https://github.com/rust-cli/human-panic/commits/a7135d1e8c87409e3f553a761e2b2caa24d849c9)] catch (Yoshua Wuyts) - [[`0129328ce4`](https://github.com/rust-cli/human-panic/commits/0129328ce4472190366ac7835aed003d68aeb088)] . (Yoshua Wuyts) ### Stats ```diff .editorconfig | 25 +-- .gitignore | 3 +- .travis.yml | 8 +- Cargo.lock | 391 +++++++++++++++++++++++++++++++++- Cargo.toml | 11 +- README.md | 51 +---- examples/panic.rs | 9 +- src/lib.rs | 130 ++--------- src/report.rs | 22 +-- tests/custom-panic/Cargo.toml | 10 +- tests/custom-panic/src/main.rs | 14 +- tests/custom-panic/tests/integration.rs | 16 +- tests/single-panic/Cargo.toml | 10 +- tests/single-panic/src/main.rs | 9 +- tests/single-panic/tests/integration.rs | 14 +- 15 files changed, 442 insertions(+), 281 deletions(-) ``` [Unreleased]: https://github.com/rust-cli/human-panic/compare/v2.0.2...HEAD [2.0.2]: https://github.com/rust-cli/human-panic/compare/v2.0.1...v2.0.2 [2.0.1]: https://github.com/rust-cli/human-panic/compare/v2.0.0...v2.0.1 [2.0.0]: https://github.com/rust-cli/human-panic/compare/v1.2.3...v2.0.0 [1.2.3]: https://github.com/rust-cli/human-panic/compare/v1.2.2...v1.2.3 [1.2.2]: https://github.com/rust-cli/human-panic/compare/v1.2.1...v1.2.2 [1.2.1]: https://github.com/rust-cli/human-panic/compare/v1.2.0...v1.2.1 [1.2.0]: https://github.com/rust-cli/human-panic/compare/v1.1.5...v1.2.0 [1.1.5]: https://github.com/rust-cli/human-panic/compare/v1.1.4...v1.1.5 [1.1.4]: https://github.com/rust-cli/human-panic/compare/v1.1.3...v1.1.4 [1.1.3]: https://github.com/rust-cli/human-panic/compare/v1.1.2...v1.1.3 [1.1.2]: https://github.com/rust-cli/human-panic/compare/v1.1.1...v1.1.2 [1.1.1]: https://github.com/rust-cli/human-panic/compare/v1.1.0...v1.1.1 [1.1.0]: https://github.com/rust-cli/argfile/compare/v1.0.3...v1.1.0 [v1.0.3]: https://github.com/rust-cli/argfile/compare/1.0.1...v1.0.3 human-panic-2.0.2/CONTRIBUTING.md000066400000000000000000000071361470201445200161520ustar00rootroot00000000000000# Contributing to human-panic Thanks for wanting to contribute! There are many ways to contribute and we appreciate any level you're willing to do. ## Feature Requests Need some new functionality to help? You can let us know by opening an [issue][new issue]. It's helpful to look through [all issues][all issues] in case its already being talked about. ## Bug Reports Please let us know about what problems you run into, whether in behavior or ergonomics of API. You can do this by opening an [issue][new issue]. It's helpful to look through [all issues][all issues] in case its already being talked about. ## Pull Requests Looking for an idea? Check our [issues][issues]. If it's look more open ended, it is probably best to post on the issue how you are thinking of resolving the issue so you can get feedback early in the process. We want you to be successful and it can be discouraging to find out a lot of re-work is needed. Already have an idea? It might be good to first [create an issue][new issue] to propose it so we can make sure we are aligned and lower the risk of having to re-work some of it and the discouragement that goes along with that. ### Process As a heads up, we'll be running your PR through the following gauntlet: - warnings turned to compile errors - `cargo test` - `rustfmt` - `clippy` - `rustdoc` - [`committed`](https://github.com/crate-ci/committed) as we use [Conventional](https://www.conventionalcommits.org) commit style - [`typos`](https://github.com/crate-ci/typos) to check spelling Not everything can be checked automatically though. We request that the commit history gets cleaned up. We ask that commits are atomic, meaning they are complete and have a single responsibility. PRs should tell a cohesive story, with test and refactor commits that keep the fix or feature commits simple and clear. Specifically, we would encourage - File renames be isolated into their own commit - Add tests in a commit before their feature or fix, showing the current behavior. The diff for the feature/fix commit will then show how the behavior changed, making it clearer to reviewrs and the community and showing people that the test is verifying the expected state. - e.g. [clap#5520](https://github.com/clap-rs/clap/pull/5520) Note that we are talking about ideals. We understand having a clean history requires more advanced git skills; feel free to ask us for help! We might even suggest where it would work to be lax. We also understand that editing some early commits may cause a lot of churn with merge conflicts which can make it not worth editing all of the history. For code organization, we recommend - Grouping `impl` blocks next to their type (or trait) - Grouping private items after the `pub` item that uses them. - The intent is to help people quickly find the "relevant" details, allowing them to "dig deeper" as needed. Or put another way, the `pub` items serve as a table-of-contents. - The exact order is fuzzy; do what makes sense ## Releasing Pre-requisites - Running `cargo login` - A member of `rust-cli:Maintainers` - Push permission to the repo - [`cargo-release`](https://github.com/crate-ci/cargo-release/) When we're ready to release, a project owner should do the following 1. Update the changelog (see `cargo release changes` for ideas) 2. Determine what the next version is, according to semver 3. Run [`cargo release -x `](https://github.com/crate-ci/cargo-release) [issues]: https://github.com/rust-cli/human-panic/issues [new issue]: https://github.com/rust-cli/human-panic/issues/new [all issues]: https://github.com/rust-cli/human-panic/issues?utf8=%E2%9C%93&q=is%3Aissue human-panic-2.0.2/Cargo.lock000066400000000000000000000453221470201445200156250ustar00rootroot00000000000000# This file is automatically @generated by Cargo. # It is not intended for manual editing. version = 3 [[package]] name = "addr2line" version = "0.21.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8a30b2e23b9e17a9f90641c7ab1549cd9b44f296d3ccbf309d2863cfe398a0cb" dependencies = [ "gimli", ] [[package]] name = "adler" version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" [[package]] name = "anstream" version = "0.6.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4cd2405b3ac1faab2990b74d728624cd9fd115651fcecc7c2d8daf01376275ba" dependencies = [ "anstyle", "anstyle-parse", "anstyle-query", "anstyle-wincon", "colorchoice", "utf8parse", ] [[package]] name = "anstyle" version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7079075b41f533b8c61d2a4d073c4676e1f8b249ff94a393b0595db304e0dd87" [[package]] name = "anstyle-parse" version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "317b9a89c1868f5ea6ff1d9539a69f45dffc21ce321ac1fd1160dfa48c8e2140" dependencies = [ "utf8parse", ] [[package]] name = "anstyle-query" version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5ca11d4be1bab0c8bc8734a9aa7bf4ee8316d462a08c6ac5052f888fef5b494b" dependencies = [ "windows-sys 0.48.0", ] [[package]] name = "anstyle-wincon" version = "3.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f0699d10d2f4d628a98ee7b57b289abbc98ff3bad977cb3152709d4bf2330628" dependencies = [ "anstyle", "windows-sys 0.48.0", ] [[package]] name = "backtrace" version = "0.3.69" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2089b7e3f35b9dd2d0ed921ead4f6d318c27680d4a5bd167b3ee120edb105837" dependencies = [ "addr2line", "cc", "cfg-if", "libc", "miniz_oxide", "object", "rustc-demangle", ] [[package]] name = "bitflags" version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" [[package]] name = "bitflags" version = "2.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b048fb63fd8b5923fc5aa7b340d8e156aec7ec02f0c78fa8a6ddc2613f6f71de" [[package]] name = "cc" version = "1.0.83" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f1174fb0b6ec23863f8b971027804a42614e347eafb0a95bf0b12cdae21fc4d0" dependencies = [ "libc", ] [[package]] name = "cfg-if" version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "colorchoice" version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "acbf1af155f9b9ef647e42cdc158db4b64a1b61f743629225fde6f3e0be2a7c7" [[package]] name = "content_inspector" version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b7bda66e858c683005a53a9a60c69a4aca7eeaa45d124526e389f7aec8e62f38" dependencies = [ "memchr", ] [[package]] name = "custom-panic-test" version = "0.1.0" dependencies = [ "human-panic", "snapbox", ] [[package]] name = "dunce" version = "1.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "92773504d58c093f6de2459af4af33faa518c13451eb8f2b5698ed3d36e7c813" [[package]] name = "equivalent" version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" [[package]] name = "errno" version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "534c5cf6194dfab3db3242765c03bbe257cf92f22b38f6bc0c58d59108a820ba" dependencies = [ "libc", "windows-sys 0.52.0", ] [[package]] name = "fastrand" version = "2.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e8c02a5121d4ea3eb16a80748c74f5549a5665e4c21333c6098f283870fbdea6" [[package]] name = "filetime" version = "0.2.25" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "35c0522e981e68cbfa8c3f978441a5f34b30b96e146b33cd3359176b50fe8586" dependencies = [ "cfg-if", "libc", "libredox", "windows-sys 0.59.0", ] [[package]] name = "getrandom" version = "0.2.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fe9006bed769170c11f845cf00c7c1e9092aeb3f268e007c3e760ac68008070f" dependencies = [ "cfg-if", "libc", "wasi", ] [[package]] name = "gimli" version = "0.28.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6fb8d784f27acf97159b40fc4db5ecd8aa23b9ad5ef69cdd136d3bc80665f0c0" [[package]] name = "hashbrown" version = "0.14.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f93e7192158dbcda357bdec5fb5788eebf8bbac027f3f33e719d29135ae84156" [[package]] name = "human-panic" version = "2.0.2" dependencies = [ "anstream", "anstyle", "backtrace", "os_info", "serde", "serde_derive", "toml", "uuid", ] [[package]] name = "indexmap" version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d530e1a18b1cb4c484e6e34556a0d948706958449fca0cab753d649f2bce3d1f" dependencies = [ "equivalent", "hashbrown", ] [[package]] name = "libc" version = "0.2.150" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "89d92a4743f9a61002fae18374ed11e7973f530cb3a3255fb354818118b2203c" [[package]] name = "libredox" version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c0ff37bd590ca25063e35af745c343cb7a0271906fb7b37e4813e8f79f00268d" dependencies = [ "bitflags 2.6.0", "libc", "redox_syscall 0.5.7", ] [[package]] name = "linux-raw-sys" version = "0.4.14" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "78b3ae25bc7c8c38cec158d1f2757ee79e9b3740fbc7ccf0e59e4b08d793fa89" [[package]] name = "log" version = "0.4.20" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b5e6163cb8c49088c2c36f57875e58ccd8c87c7427f7fbd50ea6710b2f3f2e8f" [[package]] name = "memchr" version = "2.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f665ee40bc4a3c5590afb1e9677db74a508659dfd71e126420da8274909a0167" [[package]] name = "miniz_oxide" version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e7810e0be55b428ada41041c41f32c9f1a42817901b4ccf45fa3d4b6561e74c7" dependencies = [ "adler", ] [[package]] name = "normalize-line-endings" version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "61807f77802ff30975e01f4f071c8ba10c022052f98b3294119f3e615d13e5be" [[package]] name = "object" version = "0.32.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9cf5f9dd3933bd50a9e1f149ec995f39ae2c496d31fd772c1fd45ebc27e902b0" dependencies = [ "memchr", ] [[package]] name = "os_info" version = "3.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "006e42d5b888366f1880eda20371fedde764ed2213dc8496f49622fa0c99cd5e" dependencies = [ "log", "serde", "winapi", ] [[package]] name = "os_pipe" version = "1.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0ae859aa07428ca9a929b936690f8b12dc5f11dd8c6992a18ca93919f28bc177" dependencies = [ "libc", "windows-sys 0.48.0", ] [[package]] name = "proc-macro2" version = "1.0.69" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "134c189feb4956b20f6f547d2cf727d4c0fe06722b20a0eec87ed445a97f92da" dependencies = [ "unicode-ident", ] [[package]] name = "quote" version = "1.0.33" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5267fca4496028628a95160fc423a33e8b2e6af8a5302579e322e4b520293cae" dependencies = [ "proc-macro2", ] [[package]] name = "redox_syscall" version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4722d768eff46b75989dd134e5c353f0d6296e5aaa3132e776cbdb56be7731aa" dependencies = [ "bitflags 1.3.2", ] [[package]] name = "redox_syscall" version = "0.5.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9b6dfecf2c74bce2466cabf93f6664d6998a69eb21e39f4207930065b27b771f" dependencies = [ "bitflags 2.6.0", ] [[package]] name = "rustc-demangle" version = "0.1.23" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d626bb9dae77e28219937af045c257c28bfd3f69333c512553507f5f9798cb76" [[package]] name = "rustix" version = "0.38.28" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "72e572a5e8ca657d7366229cdde4bd14c4eb5499a9573d4d366fe1b599daa316" dependencies = [ "bitflags 2.6.0", "errno", "libc", "linux-raw-sys", "windows-sys 0.52.0", ] [[package]] name = "same-file" version = "1.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "93fc1dc3aaa9bfed95e02e6eadabb4baf7e3078b0bd1b4d7b6b0b68378900502" dependencies = [ "winapi-util", ] [[package]] name = "serde" version = "1.0.192" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bca2a08484b285dcb282d0f67b26cadc0df8b19f8c12502c13d966bf9482f001" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" version = "1.0.192" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d6c7207fbec9faa48073f3e3074cbe553af6ea512d7c21ba46e434e70ea9fbc1" dependencies = [ "proc-macro2", "quote", "syn", ] [[package]] name = "serde_spanned" version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "12022b835073e5b11e90a14f86838ceb1c8fb0325b72416845c487ac0fa95e80" dependencies = [ "serde", ] [[package]] name = "similar" version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2aeaf503862c419d66959f5d7ca015337d864e9c49485d771b732e2a20453597" [[package]] name = "single-panic-test" version = "0.1.0" dependencies = [ "human-panic", "snapbox", ] [[package]] name = "snapbox" version = "0.6.17" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "840b73eb3148bc3cbc10ebe00ec9bc6d96033e658d022c4adcbf3f35596fd64a" dependencies = [ "anstream", "anstyle", "content_inspector", "dunce", "filetime", "libc", "normalize-line-endings", "os_pipe", "similar", "snapbox-macros", "tempfile", "wait-timeout", "walkdir", "windows-sys 0.59.0", ] [[package]] name = "snapbox-macros" version = "0.3.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "16569f53ca23a41bb6f62e0a5084aa1661f4814a67fa33696a79073e03a664af" dependencies = [ "anstream", ] [[package]] name = "syn" version = "2.0.39" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "23e78b90f2fcf45d3e842032ce32e3f2d1545ba6636271dcbf24fa306d87be7a" dependencies = [ "proc-macro2", "quote", "unicode-ident", ] [[package]] name = "tempfile" version = "3.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "01ce4141aa927a6d1bd34a041795abd0db1cccba5d5f24b009f694bdf3a1f3fa" dependencies = [ "cfg-if", "fastrand", "redox_syscall 0.4.1", "rustix", "windows-sys 0.52.0", ] [[package]] name = "toml" version = "0.8.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a1a195ec8c9da26928f773888e0742ca3ca1040c6cd859c919c9f59c1954ab35" dependencies = [ "serde", "serde_spanned", "toml_datetime", "toml_edit", ] [[package]] name = "toml_datetime" version = "0.6.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3550f4e9685620ac18a50ed434eb3aec30db8ba93b0287467bca5826ea25baf1" dependencies = [ "serde", ] [[package]] name = "toml_edit" version = "0.21.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d34d383cd00a163b4a5b85053df514d45bc330f6de7737edfe0a93311d1eaa03" dependencies = [ "indexmap", "serde", "serde_spanned", "toml_datetime", ] [[package]] name = "unicode-ident" version = "1.0.12" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" [[package]] name = "utf8parse" version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "711b9620af191e0cdc7468a8d14e709c3dcdb115b36f838e601583af800a370a" [[package]] name = "uuid" version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "88ad59a7560b41a70d191093a945f0b87bc1deeda46fb237479708a1d6b6cdfc" dependencies = [ "getrandom", ] [[package]] name = "wait-timeout" version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9f200f5b12eb75f8c1ed65abd4b2db8a6e1b138a20de009dacee265a2498f3f6" dependencies = [ "libc", ] [[package]] name = "walkdir" version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "29790946404f91d9c5d06f9874efddea1dc06c5efe94541a7d6863108e3a5e4b" dependencies = [ "same-file", "winapi-util", ] [[package]] name = "wasi" version = "0.11.0+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] name = "winapi" version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" dependencies = [ "winapi-i686-pc-windows-gnu", "winapi-x86_64-pc-windows-gnu", ] [[package]] name = "winapi-i686-pc-windows-gnu" version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" [[package]] name = "winapi-util" version = "0.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cf221c93e13a30d793f7645a0e7762c55d169dbb0a49671918a2319d289b10bb" dependencies = [ "windows-sys 0.48.0", ] [[package]] name = "winapi-x86_64-pc-windows-gnu" version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" [[package]] name = "windows-sys" version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" dependencies = [ "windows-targets 0.48.5", ] [[package]] name = "windows-sys" version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" dependencies = [ "windows-targets 0.52.6", ] [[package]] name = "windows-sys" version = "0.59.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b" dependencies = [ "windows-targets 0.52.6", ] [[package]] name = "windows-targets" version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c" dependencies = [ "windows_aarch64_gnullvm 0.48.5", "windows_aarch64_msvc 0.48.5", "windows_i686_gnu 0.48.5", "windows_i686_msvc 0.48.5", "windows_x86_64_gnu 0.48.5", "windows_x86_64_gnullvm 0.48.5", "windows_x86_64_msvc 0.48.5", ] [[package]] name = "windows-targets" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" dependencies = [ "windows_aarch64_gnullvm 0.52.6", "windows_aarch64_msvc 0.52.6", "windows_i686_gnu 0.52.6", "windows_i686_gnullvm", "windows_i686_msvc 0.52.6", "windows_x86_64_gnu 0.52.6", "windows_x86_64_gnullvm 0.52.6", "windows_x86_64_msvc 0.52.6", ] [[package]] name = "windows_aarch64_gnullvm" version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" [[package]] name = "windows_aarch64_gnullvm" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" [[package]] name = "windows_aarch64_msvc" version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" [[package]] name = "windows_aarch64_msvc" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" [[package]] name = "windows_i686_gnu" version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" [[package]] name = "windows_i686_gnu" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" [[package]] name = "windows_i686_gnullvm" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" [[package]] name = "windows_i686_msvc" version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" [[package]] name = "windows_i686_msvc" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" [[package]] name = "windows_x86_64_gnu" version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" [[package]] name = "windows_x86_64_gnu" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" [[package]] name = "windows_x86_64_gnullvm" version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" [[package]] name = "windows_x86_64_gnullvm" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" [[package]] name = "windows_x86_64_msvc" version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" [[package]] name = "windows_x86_64_msvc" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" human-panic-2.0.2/Cargo.toml000066400000000000000000000073431470201445200156510ustar00rootroot00000000000000[workspace] members = [ "tests/single-panic", "tests/custom-panic", ] resolver = "2" [workspace.package] repository = "https://github.com/rust-cli/human-panic" license = "MIT OR Apache-2.0" edition = "2021" rust-version = "1.74" # MSRV include = [ "build.rs", "src/**/*", "Cargo.toml", "Cargo.lock", "LICENSE*", "README.md", "benches/**/*", "examples/**/*" ] [workspace.lints.rust] rust_2018_idioms = { level = "warn", priority = -1 } unreachable_pub = "warn" unsafe_op_in_unsafe_fn = "warn" unused_lifetimes = "warn" unused_macro_rules = "warn" unused_qualifications = "warn" [workspace.lints.clippy] bool_assert_comparison = "allow" branches_sharing_code = "allow" checked_conversions = "warn" collapsible_else_if = "allow" create_dir = "warn" dbg_macro = "warn" debug_assert_with_mut_call = "warn" doc_markdown = "warn" empty_enum = "warn" enum_glob_use = "warn" expl_impl_clone_on_copy = "warn" explicit_deref_methods = "warn" explicit_into_iter_loop = "warn" fallible_impl_from = "warn" filter_map_next = "warn" flat_map_option = "warn" float_cmp_const = "warn" fn_params_excessive_bools = "warn" from_iter_instead_of_collect = "warn" if_same_then_else = "allow" implicit_clone = "warn" imprecise_flops = "warn" inconsistent_struct_constructor = "warn" inefficient_to_string = "warn" infinite_loop = "warn" invalid_upcast_comparisons = "warn" large_digit_groups = "warn" large_stack_arrays = "warn" large_types_passed_by_value = "warn" let_and_return = "allow" # sometimes good to name what you are returning linkedlist = "warn" lossy_float_literal = "warn" macro_use_imports = "warn" mem_forget = "warn" mutex_integer = "warn" needless_continue = "warn" needless_for_each = "warn" negative_feature_names = "warn" path_buf_push_overwrite = "warn" ptr_as_ptr = "warn" rc_mutex = "warn" redundant_feature_names = "warn" ref_option_ref = "warn" rest_pat_in_fully_bound_structs = "warn" same_functions_in_if_condition = "warn" self_named_module_files = "warn" semicolon_if_nothing_returned = "warn" str_to_string = "warn" string_add = "warn" string_add_assign = "warn" string_lit_as_bytes = "warn" string_to_string = "warn" todo = "warn" trait_duplication_in_bounds = "warn" uninlined_format_args = "warn" verbose_file_reads = "warn" wildcard_imports = "warn" zero_sized_map_values = "warn" [package] name = "human-panic" version = "2.0.2" description = "Panic messages for humans" homepage = "https://github.com/rust-cli/human-panic" categories = ["command-line-interface"] keywords = ["cli", "panic"] repository.workspace = true license.workspace = true edition.workspace = true rust-version.workspace = true include.workspace = true [package.metadata.docs.rs] all-features = true rustdoc-args = ["--cfg", "docsrs"] [package.metadata.release] pre-release-replacements = [ {file="CHANGELOG.md", search="Unreleased", replace="{{version}}", min=1}, {file="CHANGELOG.md", search="\\.\\.\\.HEAD", replace="...{{tag_name}}", exactly=1}, {file="CHANGELOG.md", search="ReleaseDate", replace="{{date}}", min=1}, {file="CHANGELOG.md", search="", replace="\n## [Unreleased] - ReleaseDate\n", exactly=1}, {file="CHANGELOG.md", search="", replace="\n[Unreleased]: https://github.com/rust-cli/human-panic/compare/{{tag_name}}...HEAD", exactly=1}, ] [features] default = ["color"] nightly = [] color = ["dep:anstyle", "dep:anstream"] [dependencies] anstyle = { version = "1.0.0", optional = true } anstream = { version = "0.6.7", optional = true } uuid = { version = "1.3.0", features = ["v4"], default-features = false } serde_derive = "1.0.152" toml = { version = "0.8.8", default-features = false, features = ["display"] } serde = "1.0.152" os_info = "3.6.0" backtrace = "0.3.69" [lints] workspace = true human-panic-2.0.2/LICENSE-APACHE000066400000000000000000000261361470201445200156460ustar00rootroot00000000000000 Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions. "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and (b) You must cause any modified files to carry prominent notices stating that You changed the files; and (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. END OF TERMS AND CONDITIONS APPENDIX: How to apply the Apache License to your work. To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "{}" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives. Copyright {yyyy} {name of copyright owner} Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. human-panic-2.0.2/LICENSE-MIT000066400000000000000000000020461470201445200153500ustar00rootroot00000000000000Copyright (c) Individual contributors Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. human-panic-2.0.2/README.md000066400000000000000000000107571470201445200152030ustar00rootroot00000000000000# human-panic [![crates.io version][1]][2] [![build status][3]][4] [![downloads][5]][6] [![docs.rs docs][7]][8] Panic messages for humans. Handles panics by calling [`std::panic::set_hook`](https://doc.rust-lang.org/std/panic/fn.set_hook.html) to make errors nice for humans. - [Documentation][8] - [Crates.io][2] ## Why? When you're building a CLI, polish is super important. Even though Rust is pretty great at safety, it's not unheard of to access the wrong index in a vector or have an assert fail somewhere. When an error eventually occurs, you probably will want to know about it. So instead of just providing an error message on the command line, we can create a call to action for people to submit a report. This should empower people to engage in communication, lowering the chances people might get frustrated. And making it easier to figure out what might be causing bugs. ### Default Output ```txt thread 'main' panicked at 'oops', examples/main.rs:2:3 note: Run with `RUST_BACKTRACE=1` for a backtrace. ``` ### Human-Panic Output ```txt Well, this is embarrassing. human-panic had a problem and crashed. To help us diagnose the problem you can send us a crash report. We have generated a report file at "/var/folders/zw/bpfvmq390lv2c6gn_6byyv0w0000gn/T/report-8351cad6-d2b5-4fe8-accd-1fcbf4538792.toml". Submit an issue or email with the subject of "human-panic Crash Report" and include the report as an attachment. - Homepage: https://github.com/rust-cli/human-panic - Authors: Yoshua Wuyts We take privacy seriously, and do not perform any automated error collection. In order to improve the software, we rely on people to submit reports. Thank you kindly! ``` The error dump file generated by `human-panic` contains the following fields. ```toml name = 'single-panic-test' operating_system = 'unix:Unknown' crate_version = '0.1.0' explanation = ''' Cause: OMG EVERYTHING IS ON FIRE!!!. Panic occurred in file 'tests/single-panic/src/main.rs' at line 8 ''' method = 'Panic' backtrace = ''' stack backtrace: 0: 0x55fa0ed4c1b4 - backtrace::backtrace::libunwind::trace::h69e50feca54bfb84 at /home/spacekookie/.cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.6/src/backtrace/libunwind.rs:53 - backtrace::backtrace::trace::h42967341e0b01ccc at /home/spacekookie/.cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.6/src/backtrace/mod.rs:42 # ... 8: 0x55fa0ebaac8d - single_panic_test::main::h56a3d326bcecfc36 at tests/single-panic/src/main.rs:8 9: 0x55fa0ebaae91 - std::rt::lang_start::{{closure}}::h09d28d8540038bf8 at /checkout/src/libstd/rt.rs:74 10: 0x55fa0ed732f7 - std::rt::lang_start_internal::{{closure}}::h2e4baf0a27c956a3 at libstd/rt.rs:59 - std::panicking::try::do_call::h73f98ed0647c7274 at libstd/panicking.rs:305 11: 0x55fa0ed8551e - __rust_maybe_catch_panic at libpanic_unwind/lib.rs:101 12: 0x55fa0ed6f7f5 - std::panicking::try::h18fbb145180d4cd9 at libstd/panicking.rs:284 - std::panic::catch_unwind::hc4b6a212a30b4bc5 at libstd/panic.rs:361 - std::rt::lang_start_internal::h8b001b4244930d51 at libstd/rt.rs:58 13: 0x55fa0ebaae71 - std::rt::lang_start::h1b1de624209f414a at /checkout/src/libstd/rt.rs:74 14: 0x55fa0ebaacbd - main 15: 0x7f9946132f29 - __libc_start_main 16: 0x55fa0eba9b79 - _start 17: 0x0 - ''' ``` ## Usage ```rust no_run use human_panic::setup_panic; fn main() { setup_panic!(); println!("A normal log message"); panic!("OMG EVERYTHING IS ON FIRE!!!") } ``` It only displays a human-friendly panic message in release mode: ```sh $ cargo run --release ``` ## Installation ```sh $ cargo add human-panic ``` ## License [MIT](./LICENSE-MIT) OR [Apache-2.0](./LICENSE-APACHE) [1]: https://img.shields.io/crates/v/human-panic.svg?style=flat-square [2]: https://crates.io/crates/human-panic [3]: https://img.shields.io/travis/rust-cli/human-panic.svg?style=flat-square [4]: https://travis-ci.org/rust-cli/human-panic [5]: https://img.shields.io/crates/d/human-panic.svg?style=flat-square [6]: https://crates.io/crates/human-panic [7]: https://docs.rs/human-panic/badge.svg [8]: https://docs.rs/human-panic human-panic-2.0.2/committed.toml000066400000000000000000000001231470201445200165700ustar00rootroot00000000000000style="conventional" ignore_author_re="(dependabot|renovate)" merge_commit = false human-panic-2.0.2/deny.toml000066400000000000000000000252411470201445200155520ustar00rootroot00000000000000# Note that all fields that take a lint level have these possible values: # * deny - An error will be produced and the check will fail # * warn - A warning will be produced, but the check will not fail # * allow - No warning or error will be produced, though in some cases a note # will be # Root options # The graph table configures how the dependency graph is constructed and thus # which crates the checks are performed against [graph] # If 1 or more target triples (and optionally, target_features) are specified, # only the specified targets will be checked when running `cargo deny check`. # This means, if a particular package is only ever used as a target specific # dependency, such as, for example, the `nix` crate only being used via the # `target_family = "unix"` configuration, that only having windows targets in # this list would mean the nix crate, as well as any of its exclusive # dependencies not shared by any other crates, would be ignored, as the target # list here is effectively saying which targets you are building for. targets = [ # The triple can be any string, but only the target triples built in to # rustc (as of 1.40) can be checked against actual config expressions #"x86_64-unknown-linux-musl", # You can also specify which target_features you promise are enabled for a # particular target. target_features are currently not validated against # the actual valid features supported by the target architecture. #{ triple = "wasm32-unknown-unknown", features = ["atomics"] }, ] # When creating the dependency graph used as the source of truth when checks are # executed, this field can be used to prune crates from the graph, removing them # from the view of cargo-deny. This is an extremely heavy hammer, as if a crate # is pruned from the graph, all of its dependencies will also be pruned unless # they are connected to another crate in the graph that hasn't been pruned, # so it should be used with care. The identifiers are [Package ID Specifications] # (https://doc.rust-lang.org/cargo/reference/pkgid-spec.html) #exclude = [] # If true, metadata will be collected with `--all-features`. Note that this can't # be toggled off if true, if you want to conditionally enable `--all-features` it # is recommended to pass `--all-features` on the cmd line instead all-features = false # If true, metadata will be collected with `--no-default-features`. The same # caveat with `all-features` applies no-default-features = false # If set, these feature will be enabled when collecting metadata. If `--features` # is specified on the cmd line they will take precedence over this option. #features = [] # The output table provides options for how/if diagnostics are outputted [output] # When outputting inclusion graphs in diagnostics that include features, this # option can be used to specify the depth at which feature edges will be added. # This option is included since the graphs can be quite large and the addition # of features from the crate(s) to all of the graph roots can be far too verbose. # This option can be overridden via `--feature-depth` on the cmd line feature-depth = 1 # This section is considered when running `cargo deny check advisories` # More documentation for the advisories section can be found here: # https://embarkstudios.github.io/cargo-deny/checks/advisories/cfg.html [advisories] # The path where the advisory databases are cloned/fetched into #db-path = "$CARGO_HOME/advisory-dbs" # The url(s) of the advisory databases to use #db-urls = ["https://github.com/rustsec/advisory-db"] # A list of advisory IDs to ignore. Note that ignored advisories will still # output a note when they are encountered. ignore = [ #"RUSTSEC-0000-0000", #{ id = "RUSTSEC-0000-0000", reason = "you can specify a reason the advisory is ignored" }, #"a-crate-that-is-yanked@0.1.1", # you can also ignore yanked crate versions if you wish #{ crate = "a-crate-that-is-yanked@0.1.1", reason = "you can specify why you are ignoring the yanked crate" }, ] # If this is true, then cargo deny will use the git executable to fetch advisory database. # If this is false, then it uses a built-in git library. # Setting this to true can be helpful if you have special authentication requirements that cargo-deny does not support. # See Git Authentication for more information about setting up git authentication. #git-fetch-with-cli = true # This section is considered when running `cargo deny check licenses` # More documentation for the licenses section can be found here: # https://embarkstudios.github.io/cargo-deny/checks/licenses/cfg.html [licenses] # List of explicitly allowed licenses # See https://spdx.org/licenses/ for list of possible licenses # [possible values: any SPDX 3.11 short identifier (+ optional exception)]. allow = [ "MIT", "MIT-0", "Apache-2.0", "BSD-3-Clause", "MPL-2.0", "Unicode-DFS-2016", "CC0-1.0", "ISC", "OpenSSL", ] # The confidence threshold for detecting a license from license text. # The higher the value, the more closely the license text must be to the # canonical license text of a valid SPDX license file. # [possible values: any between 0.0 and 1.0]. confidence-threshold = 0.8 # Allow 1 or more licenses on a per-crate basis, so that particular licenses # aren't accepted for every possible crate as with the normal allow list exceptions = [ # Each entry is the crate and version constraint, and its specific allow # list #{ allow = ["Zlib"], crate = "adler32" }, ] # Some crates don't have (easily) machine readable licensing information, # adding a clarification entry for it allows you to manually specify the # licensing information [[licenses.clarify]] # The package spec the clarification applies to crate = "ring" # The SPDX expression for the license requirements of the crate expression = "MIT AND ISC AND OpenSSL" # One or more files in the crate's source used as the "source of truth" for # the license expression. If the contents match, the clarification will be used # when running the license check, otherwise the clarification will be ignored # and the crate will be checked normally, which may produce warnings or errors # depending on the rest of your configuration license-files = [ # Each entry is a crate relative path, and the (opaque) hash of its contents { path = "LICENSE", hash = 0xbd0eed23 } ] [licenses.private] # If true, ignores workspace crates that aren't published, or are only # published to private registries. # To see how to mark a crate as unpublished (to the official registry), # visit https://doc.rust-lang.org/cargo/reference/manifest.html#the-publish-field. ignore = true # One or more private registries that you might publish crates to, if a crate # is only published to private registries, and ignore is true, the crate will # not have its license(s) checked registries = [ #"https://sekretz.com/registry ] # This section is considered when running `cargo deny check bans`. # More documentation about the 'bans' section can be found here: # https://embarkstudios.github.io/cargo-deny/checks/bans/cfg.html [bans] # Lint level for when multiple versions of the same crate are detected multiple-versions = "warn" # Lint level for when a crate version requirement is `*` wildcards = "allow" # The graph highlighting used when creating dotgraphs for crates # with multiple versions # * lowest-version - The path to the lowest versioned duplicate is highlighted # * simplest-path - The path to the version with the fewest edges is highlighted # * all - Both lowest-version and simplest-path are used highlight = "all" # The default lint level for `default` features for crates that are members of # the workspace that is being checked. This can be overridden by allowing/denying # `default` on a crate-by-crate basis if desired. workspace-default-features = "allow" # The default lint level for `default` features for external crates that are not # members of the workspace. This can be overridden by allowing/denying `default` # on a crate-by-crate basis if desired. external-default-features = "allow" # List of crates that are allowed. Use with care! allow = [ #"ansi_term@0.11.0", #{ crate = "ansi_term@0.11.0", reason = "you can specify a reason it is allowed" }, ] # List of crates to deny deny = [ #"ansi_term@0.11.0", #{ crate = "ansi_term@0.11.0", reason = "you can specify a reason it is banned" }, # Wrapper crates can optionally be specified to allow the crate when it # is a direct dependency of the otherwise banned crate #{ crate = "ansi_term@0.11.0", wrappers = ["this-crate-directly-depends-on-ansi_term"] }, ] # List of features to allow/deny # Each entry the name of a crate and a version range. If version is # not specified, all versions will be matched. #[[bans.features]] #crate = "reqwest" # Features to not allow #deny = ["json"] # Features to allow #allow = [ # "rustls", # "__rustls", # "__tls", # "hyper-rustls", # "rustls", # "rustls-pemfile", # "rustls-tls-webpki-roots", # "tokio-rustls", # "webpki-roots", #] # If true, the allowed features must exactly match the enabled feature set. If # this is set there is no point setting `deny` #exact = true # Certain crates/versions that will be skipped when doing duplicate detection. skip = [ #"ansi_term@0.11.0", #{ crate = "ansi_term@0.11.0", reason = "you can specify a reason why it can't be updated/removed" }, ] # Similarly to `skip` allows you to skip certain crates during duplicate # detection. Unlike skip, it also includes the entire tree of transitive # dependencies starting at the specified crate, up to a certain depth, which is # by default infinite. skip-tree = [ #"ansi_term@0.11.0", # will be skipped along with _all_ of its direct and transitive dependencies #{ crate = "ansi_term@0.11.0", depth = 20 }, ] # This section is considered when running `cargo deny check sources`. # More documentation about the 'sources' section can be found here: # https://embarkstudios.github.io/cargo-deny/checks/sources/cfg.html [sources] # Lint level for what to happen when a crate from a crate registry that is not # in the allow list is encountered unknown-registry = "deny" # Lint level for what to happen when a crate from a git repository that is not # in the allow list is encountered unknown-git = "deny" # List of URLs for allowed crate registries. Defaults to the crates.io index # if not specified. If it is specified but empty, no registries are allowed. allow-registry = ["https://github.com/rust-lang/crates.io-index"] # List of URLs for allowed Git repositories allow-git = [] [sources.allow-org] # 1 or more github.com organizations to allow git sources for github = [] # 1 or more gitlab.com organizations to allow git sources for gitlab = [] # 1 or more bitbucket.org organizations to allow git sources for bitbucket = [] human-panic-2.0.2/release.toml000066400000000000000000000001031470201445200162210ustar00rootroot00000000000000owners = ["github:rust-cli:Maintainers"] allow-branch = ["master"] human-panic-2.0.2/src/000077500000000000000000000000001470201445200145015ustar00rootroot00000000000000human-panic-2.0.2/src/lib.rs000066400000000000000000000222711470201445200156210ustar00rootroot00000000000000//! Panic messages for humans //! //! Handles panics by calling //! [`std::panic::set_hook`](https://doc.rust-lang.org/std/panic/fn.set_hook.html) //! to make errors nice for humans. //! //! ## Why? //! When you're building a CLI, polish is super important. Even though Rust is //! pretty great at safety, it's not unheard of to access the wrong index in a //! vector or have an assert fail somewhere. //! //! When an error eventually occurs, you probably will want to know about it. So //! instead of just providing an error message on the command line, we can create a //! call to action for people to submit a report. //! //! This should empower people to engage in communication, lowering the chances //! people might get frustrated. And making it easier to figure out what might be //! causing bugs. //! //! ### Default Output //! //! ```txt //! thread 'main' panicked at 'oops', examples/main.rs:2:3 //! note: Run with `RUST_BACKTRACE=1` for a backtrace. //! ``` //! //! ### Human-Panic Output //! //! ```txt //! Well, this is embarrassing. //! //! human-panic had a problem and crashed. To help us diagnose the problem you can send us a crash report. //! //! We have generated a report file at "/var/folders/zw/bpfvmq390lv2c6gn_6byyv0w0000gn/T/report-8351cad6-d2b5-4fe8-accd-1fcbf4538792.toml". Submit an issue or email with the subject of "human-panic Crash Report" and include the report as an attachment. //! //! - Homepage: https://github.com/rust-ci/human-panic //! - Authors: Yoshua Wuyts //! //! We take privacy seriously, and do not perform any automated error collection. In order to improve the software, we rely on people to submit reports. //! //! Thank you kindly! #![cfg_attr(feature = "nightly", feature(panic_info_message))] #![cfg_attr(docsrs, feature(doc_auto_cfg))] #![warn(clippy::print_stderr)] #![warn(clippy::print_stdout)] pub mod report; use report::{Method, Report}; use std::borrow::Cow; use std::io::Result as IoResult; use std::panic::PanicInfo; use std::path::{Path, PathBuf}; /// A convenient metadata struct that describes a crate /// /// See [`metadata!`] pub struct Metadata { name: Cow<'static, str>, version: Cow<'static, str>, authors: Option>, homepage: Option>, support: Option>, } impl Metadata { /// See [`metadata!`] pub fn new(name: impl Into>, version: impl Into>) -> Self { Self { name: name.into(), version: version.into(), authors: None, homepage: None, support: None, } } /// The list of authors of the crate pub fn authors(mut self, value: impl Into>) -> Self { let value = value.into(); if !value.is_empty() { self.authors = value.into(); } self } /// The URL of the crate's website pub fn homepage(mut self, value: impl Into>) -> Self { let value = value.into(); if !value.is_empty() { self.homepage = value.into(); } self } /// The support information pub fn support(mut self, value: impl Into>) -> Self { let value = value.into(); if !value.is_empty() { self.support = value.into(); } self } } /// Initialize [`Metadata`] #[macro_export] macro_rules! metadata { () => {{ $crate::Metadata::new(env!("CARGO_PKG_NAME"), env!("CARGO_PKG_VERSION")) .authors(env!("CARGO_PKG_AUTHORS").replace(":", ", ")) .homepage(env!("CARGO_PKG_HOMEPAGE")) }}; } /// `human-panic` initialisation macro /// /// You can either call this macro with no arguments `setup_panic!()` or /// with a Metadata struct, if you don't want the error message to display /// the values used in your `Cargo.toml` file. /// /// The Metadata struct can't implement `Default` because of orphan rules, which /// means you need to provide all fields for initialisation. /// /// The macro should be called from within a function, for example as the first line of the /// `main()` function of the program. /// /// ``` /// use human_panic::setup_panic; /// use human_panic::Metadata; /// /// setup_panic!(Metadata::new(env!("CARGO_PKG_NAME"), env!("CARGO_PKG_VERSION")) /// .authors("My Company Support ") /// .homepage("support.mycompany.com") /// .support("- Open a support request by email to support@mycompany.com") /// ); /// ``` #[macro_export] macro_rules! setup_panic { ($meta:expr) => {{ $crate::setup_panic(|| $meta); }}; () => { $crate::setup_panic!($crate::metadata!()); }; } #[doc(hidden)] pub fn setup_panic(meta: impl Fn() -> Metadata) { #[allow(unused_imports)] use std::panic::{self, PanicInfo}; match PanicStyle::default() { PanicStyle::Debug => {} PanicStyle::Human => { let meta = meta(); panic::set_hook(Box::new(move |info: &PanicInfo<'_>| { let file_path = handle_dump(&meta, info); print_msg(file_path, &meta) .expect("human-panic: printing error message to console failed"); })); } } } /// Style of panic to be used #[non_exhaustive] #[derive(Copy, Clone, PartialEq, Eq)] pub enum PanicStyle { /// Normal panic Debug, /// Human-formatted panic Human, } impl Default for PanicStyle { fn default() -> Self { if cfg!(debug_assertions) { PanicStyle::Debug } else { match ::std::env::var("RUST_BACKTRACE") { Ok(_) => PanicStyle::Debug, Err(_) => PanicStyle::Human, } } } } /// Utility function that prints a message to our human users #[cfg(feature = "color")] pub fn print_msg>(file_path: Option

, meta: &Metadata) -> IoResult<()> { use std::io::Write as _; let stderr = anstream::stderr(); let mut stderr = stderr.lock(); write!(stderr, "{}", anstyle::AnsiColor::Red.render_fg())?; write_msg(&mut stderr, file_path, meta)?; write!(stderr, "{}", anstyle::Reset.render())?; Ok(()) } #[cfg(not(feature = "color"))] pub fn print_msg>(file_path: Option

, meta: &Metadata) -> IoResult<()> { let stderr = std::io::stderr(); let mut stderr = stderr.lock(); write_msg(&mut stderr, file_path, meta)?; Ok(()) } fn write_msg>( buffer: &mut impl std::io::Write, file_path: Option

, meta: &Metadata, ) -> IoResult<()> { let Metadata { name, authors, homepage, support, .. } = meta; writeln!(buffer, "Well, this is embarrassing.\n")?; writeln!( buffer, "{name} had a problem and crashed. To help us diagnose the \ problem you can send us a crash report.\n" )?; writeln!( buffer, "We have generated a report file at \"{}\". Submit an \ issue or email with the subject of \"{} Crash Report\" and include the \ report as an attachment.\n", match file_path { Some(fp) => format!("{}", fp.as_ref().display()), None => "".to_owned(), }, name )?; if let Some(homepage) = homepage { writeln!(buffer, "- Homepage: {homepage}")?; } if let Some(authors) = authors { writeln!(buffer, "- Authors: {authors}")?; } if let Some(support) = support { writeln!(buffer, "\nTo submit the crash report:\n\n{support}")?; } writeln!( buffer, "\nWe take privacy seriously, and do not perform any \ automated error collection. In order to improve the software, we rely on \ people to submit reports.\n" )?; writeln!(buffer, "Thank you kindly!")?; Ok(()) } /// Utility function which will handle dumping information to disk pub fn handle_dump(meta: &Metadata, panic_info: &PanicInfo<'_>) -> Option { let mut expl = String::new(); #[cfg(feature = "nightly")] let message = panic_info.message().map(|m| format!("{}", m)); #[cfg(not(feature = "nightly"))] let message = match ( panic_info.payload().downcast_ref::<&str>(), panic_info.payload().downcast_ref::(), ) { (Some(s), _) => Some((*s).to_owned()), (_, Some(s)) => Some(s.to_owned()), (None, None) => None, }; let cause = match message { Some(m) => m, None => "Unknown".into(), }; match panic_info.location() { Some(location) => expl.push_str(&format!( "Panic occurred in file '{}' at line {}\n", location.file(), location.line() )), None => expl.push_str("Panic location unknown.\n"), } let report = Report::new(&meta.name, &meta.version, Method::Panic, expl, cause); if let Ok(f) = report.persist() { Some(f) } else { use std::io::Write as _; let stderr = std::io::stderr(); let mut stderr = stderr.lock(); let _ = writeln!( stderr, "{}", report .serialize() .expect("only doing toml compatible types") ); None } } human-panic-2.0.2/src/report.rs000066400000000000000000000103061470201445200163620ustar00rootroot00000000000000//! This module encapsulates the report of a failure event. //! //! A `Report` contains the metadata collected about the event //! to construct a helpful error message. use backtrace::Backtrace; use serde_derive::Serialize; use std::error::Error; use std::fmt::Write as FmtWrite; use std::mem; use std::{env, path::Path, path::PathBuf}; use uuid::Uuid; /// Method of failure. #[derive(Debug, Serialize, Clone, Copy)] #[non_exhaustive] pub enum Method { /// Failure caused by a panic. Panic, } /// Contains metadata about the crash like the backtrace and /// information about the crate and operating system. Can /// be used to be serialized and persisted or printed as /// information to the user. #[derive(Debug, Serialize)] pub struct Report { name: String, operating_system: String, crate_version: String, explanation: String, cause: String, method: Method, backtrace: String, } impl Report { /// Create a new instance. pub fn new( name: &str, version: &str, method: Method, explanation: String, cause: String, ) -> Self { let operating_system = os_info::get().to_string(); let backtrace = render_backtrace(); Self { crate_version: version.into(), name: name.into(), operating_system, method, explanation, cause, backtrace, } } /// Serialize the `Report` to a TOML string. pub fn serialize(&self) -> Option { toml::to_string_pretty(&self).ok() } /// Write a file to disk. pub fn persist(&self) -> Result> { let uuid = Uuid::new_v4().hyphenated().to_string(); let tmp_dir = env::temp_dir(); let file_name = format!("report-{}.toml", &uuid); let file_path = Path::new(&tmp_dir).join(file_name); let toml = self.serialize().expect("only using toml-compatible types"); std::fs::write(&file_path, toml.as_bytes())?; Ok(file_path) } } fn render_backtrace() -> String { //We take padding for address and extra two letters //to pad after index. #[allow(unused_qualifications)] // needed for pre-1.80 MSRV const HEX_WIDTH: usize = mem::size_of::() * 2 + 2; //Padding for next lines after frame's address const NEXT_SYMBOL_PADDING: usize = HEX_WIDTH + 6; let mut backtrace = String::new(); //Here we iterate over backtrace frames //(each corresponds to function's stack) //We need to print its address //and symbol(e.g. function name), //if it is available let bt = Backtrace::new(); let symbols = bt .frames() .iter() .flat_map(|frame| { let symbols = frame.symbols(); if symbols.is_empty() { vec![(frame, None, "".to_owned())] } else { symbols .iter() .map(|s| { ( frame, Some(s), s.name() .map(|n| n.to_string()) .unwrap_or_else(|| "".to_owned()), ) }) .collect::>() } }) .collect::>(); let begin_unwind = "rust_begin_unwind"; let begin_unwind_start = symbols .iter() .position(|(_, _, n)| n == begin_unwind) .unwrap_or(0); for (entry_idx, (frame, symbol, name)) in symbols.iter().skip(begin_unwind_start).enumerate() { let ip = frame.ip(); let _ = writeln!(backtrace, "{entry_idx:4}: {ip:HEX_WIDTH$?} - {name}"); if let Some(symbol) = symbol { //See if there is debug information with file name and line if let (Some(file), Some(line)) = (symbol.filename(), symbol.lineno()) { let _ = writeln!( backtrace, "{:3$}at {}:{}", "", file.display(), line, NEXT_SYMBOL_PADDING ); } } } backtrace } human-panic-2.0.2/tests/000077500000000000000000000000001470201445200150545ustar00rootroot00000000000000human-panic-2.0.2/tests/custom-panic/000077500000000000000000000000001470201445200174565ustar00rootroot00000000000000human-panic-2.0.2/tests/custom-panic/Cargo.toml000066400000000000000000000005071470201445200214100ustar00rootroot00000000000000[package] name = "custom-panic-test" version = "0.1.0" authors = ["Human Panic Authors "] edition.workspace = true publish = false [package.metadata.release] release = false [dependencies] human-panic = { path = "../.." } [dev-dependencies] snapbox = { version = "0.6.4", features = ["cmd"] } human-panic-2.0.2/tests/custom-panic/src/000077500000000000000000000000001470201445200202455ustar00rootroot00000000000000human-panic-2.0.2/tests/custom-panic/src/main.rs000066400000000000000000000005561470201445200215450ustar00rootroot00000000000000use human_panic::metadata; use human_panic::setup_panic; fn main() { setup_panic!(metadata!() .authors("My Company Support "] edition.workspace = true publish = false [package.metadata.release] release = false [dependencies] human-panic = { path = "../.." } [dev-dependencies] snapbox = { version = "0.6.4", features = ["cmd", "dir"] } human-panic-2.0.2/tests/single-panic/src/000077500000000000000000000000001470201445200202145ustar00rootroot00000000000000human-panic-2.0.2/tests/single-panic/src/main.rs000066400000000000000000000006101470201445200215030ustar00rootroot00000000000000use human_panic::setup_panic; fn main() { setup_panic!(); call_inline_always() } fn call_inline_always() { inline_always(); } #[inline(always)] fn inline_always() { call_closure(); } fn call_closure() { let closure = || { do_panic(); }; closure(); } fn do_panic() { println!("A normal log message"); panic!("OMG EVERYTHING IS ON FIRE!!!"); } human-panic-2.0.2/tests/single-panic/tests/000077500000000000000000000000001470201445200205675ustar00rootroot00000000000000human-panic-2.0.2/tests/single-panic/tests/integration.rs000066400000000000000000000056021470201445200234630ustar00rootroot00000000000000#[test] #[cfg_attr(debug_assertions, ignore)] fn release() { let root = snapbox::dir::DirRoot::mutable_temp().unwrap(); let root_path = root.path().unwrap(); #[cfg(unix)] let envs = [("TMPDIR", root_path)]; #[cfg(not(unix))] let envs: [(&str, &str); 0] = []; snapbox::cmd::Command::new(snapbox::cmd::cargo_bin!("single-panic-test")) .envs(envs) .assert() .stderr_eq(snapbox::str![[r#" Well, this is embarrassing. single-panic-test had a problem and crashed. To help us diagnose the problem you can send us a crash report. We have generated a report file at "[..].toml". Submit an issue or email with the subject of "single-panic-test Crash Report" and include the report as an attachment. - Authors: Human Panic Authors We take privacy seriously, and do not perform any automated error collection. In order to improve the software, we rely on people to submit reports. Thank you kindly! "#]]) .code(101); #[cfg(unix)] { let mut files = root_path .read_dir() .unwrap() .map(|e| { let e = e.unwrap(); let path = e.path(); let content = std::fs::read_to_string(&path); (path, content) }) .collect::>(); assert_eq!(files.len(), 1, "{files:?}"); let (_, report) = files.pop().unwrap(); let report = report.unwrap(); snapbox::assert_data_eq!( report, snapbox::str![[r#" "name" = "single-panic-test" "operating_system" = "[..]" "crate_version" = "0.1.0" "explanation" = """ Panic occurred in file 'tests/single-panic/src/main.rs' at line [..] """ "cause" = "OMG EVERYTHING IS ON FIRE!!!" "method" = "Panic" "backtrace" = """ ... """ "#]] ); } root.close().unwrap(); } #[test] #[cfg_attr(not(debug_assertions), ignore)] fn debug() { let root = snapbox::dir::DirRoot::mutable_temp().unwrap(); let root_path = root.path().unwrap(); #[cfg(unix)] let envs = [("TMPDIR", root_path)]; #[cfg(not(unix))] let envs: [(&str, &str); 0] = []; snapbox::cmd::Command::new(snapbox::cmd::cargo_bin!("single-panic-test")) .envs(envs) .assert() .stderr_eq(snapbox::str![[r#" thread 'main' panicked at tests/single-panic/src/main.rs:[..]: OMG EVERYTHING IS ON FIRE!!! note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace "#]]) .code(101); #[cfg(unix)] { let files = root_path .read_dir() .unwrap() .map(|e| { let e = e.unwrap(); let path = e.path(); let content = std::fs::read_to_string(&path); (path, content) }) .collect::>(); assert!(files.is_empty(), "{files:?}"); } root.close().unwrap(); }