Skip to content

errors: stringly-typed variants in typed shells, and an anyhow dependency nothing uses #1212

Open

Description

@chappie-daemon

Measured on rewrite/main at ff045445.

  • The error types are typed shells around strings. AdminError carries Unauthorised(String), Invalid(String) and Internal(String) beside its #[from] variants (crates/nostream-admin/src/error.rs:23,27,47), so the three failures a caller most wants to distinguish are distinguished only by which string they carry. Nothing in the tree matches on those variants; they are constructed, formatted, logged.
  • Result<_, String> pockets survive in six or more places (nostream-admin/src/controllers/get_moderation_stats.rs, patch_settings.rs, utils/storage.rs, nostream-config/src/path.rs, nostream-core/src/nip03.rs with 11 occurrences, validation.rs with 3).
  • anyhow is declared and never used. Cargo.toml:14 has anyhow = "1", and the only two references in the tree are doc comments saying where it is allowed (nostream-cli/src/error.rs:1, nostreamd/src/main.rs:3). So the anyhow/thiserror boundary is a stated design with no implementation behind it: either the binaries adopt it or the dependency comes out.

The cost is not style. A stringly error cannot be matched by a caller that wants to answer 404 to one case and 500 to another, so every consumer of these types either re-parses the message or collapses the distinction.

Acceptance:

  • The three string variants in AdminError (and the equivalents in CoreError) become typed variants with the data they actually carry, and at least one caller matches on a variant instead of formatting the string.
  • The Result<_, String> pockets either become a typed error or gain a comment naming why a string is correct there.
  • anyhow is used in the binaries or removed from the workspace; the doc comments and the manifest agree.

Activity

  1. added
    rewrite
    rust
    on Nov 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    rewriterust

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions