← ClaudeAtlas

ruby-error-handlinglisted

Handle errors from the PayPal Server SDK Ruby SDK. Load before your first `rescue` around a call, or when building an error-translation layer. The class list won't tell you which statuses this SDK actually raises on, where the error body's fields live, or that the `doc/` Errors table names classes that may not exist here.
MuHamza30/paypal-api-plugin · ★ 0 · API & Backend · score 70
Install: claude install-skill MuHamza30/paypal-api-plugin
# Error handling for an APIMatic Ruby SDK Endpoint methods **raise** on error responses. Everything they raise descends from `PaypalServerSdk::APIException`, which extends `CoreLibrary::ApiException` from the `apimatic_core` gem — so a single `rescue PaypalServerSdk::APIException` is a complete safety net for API errors. ## Which exception does an operation raise? Two shapes, and the difference is generated per operation: - **Typed subclass** — where a status code has an error model, there is a class under `lib/paypal_server_sdk/exceptions/` (`class {OperationException} < APIException`) and the operation registers it for that status. The instance carries the error body's fields as ordinary attributes. - **Base `APIException`** — everything else. This is the common case: many operations document no error model at all. You do not have to guess. Two places tell you: 1. **`doc/controllers/{controller}.md`** — each operation has an **Errors table** mapping HTTP status code → description → exception class. Read it first, then confirm each class against `ls lib/paypal_server_sdk/exceptions/`. 2. The operation in the controller folder under `lib/paypal_server_sdk/` — where this build registers errors at all (the callout below settles that), its response handler holds a `.local_error('{status}', '{message}', {ExceptionClass})` line per documented error, and a `GLOBAL_ERRORS` constant on the controller base class supplies the catch-all. The folder (`co