openapi-rust-sdk icon indicating copy to clipboard operation
openapi-rust-sdk copied to clipboard

Add SDK error type for custom error propagation

Open manish-raana opened this issue 6 months ago • 0 comments

Fixes #11.

This change adds a public openapi_sdk::Error type and openapi_sdk::Result alias so downstream projects can integrate SDK failures into their own error enums with From<openapi_sdk::Error> and continue using ? in existing Result pipelines.

Changes

  • Added openapi_sdk::Error with variants for HTTP errors, invalid headers, and invalid HTTP methods.
  • Implemented Display, std::error::Error, and From conversions for wrapped error types.
  • Replaced panic-prone unwrap() calls for header and method parsing with returned SDK errors.
  • Added error_for_status() handling for non-2xx HTTP responses.
  • Added regression tests for custom error propagation.
  • Documented custom error integration in README and crates.io docs.

Verification

  • cargo fmt --all -- --check
  • cargo test
  • cargo test --examples

manish-raana avatar May 12 '26 10:05 manish-raana