Add error handling strategy and shared error types #12
Notifications
Total Time Spent: 5 minutes
connor
5 minutes
No due date set.
Dependencies
No dependencies set.
Reference: Shanty/Main#12
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
As a multi-crate workspace, Shanty needs a consistent error handling strategy. Each crate will have its own error conditions, but they need to compose cleanly — especially when the web backend calls into library crates and needs to translate errors into HTTP responses.
This issue covers:
Shared error types — create an error module (in
shanty-dbor a newshanty-corecrate) that defines:DatabaseError,IoError,NetworkError,ConfigError,NotFoundError,ExternalToolError(for yt-dlp, etc.)std::error::Error,Display, andFromconversions for common typesthiserrorfor ergonomic error type derivationPer-crate errors — each crate should define its own error type that wraps the shared errors plus crate-specific variants. For example,
shanty-tagmight haveTagError::NoMatchFound,TagError::ApiRateLimited, etc.Web error mapping — in
shanty-web, implementactix_web::ResponseErrorfor the error types so they automatically convert to appropriate HTTP responses (404 for NotFound, 500 for internal errors, 429 for rate limits, etc.)Result type alias — define a
Result<T> = std::result::Result<T, ShantyError>alias for convenienceAcceptance Criteria
thiserror(or equivalent) is used for clean error type definitionsFromimplementations allow easy error propagation with?main)Dependencies