@@ -22,6 +22,7 @@ IAM: The documentation for the StackOne Unified API - IAM
2222 * [ Authentication] ( #authentication )
2323 * [ Available Resources and Operations] ( #available-resources-and-operations )
2424 * [ Retries] ( #retries )
25+ * [ Error Handling] ( #error-handling )
2526 * [ Server Selection] ( #server-selection )
2627* [ Development] ( #development )
2728 * [ Maturity] ( #maturity )
420421```
421422<!-- End Retries [retries] -->
422423
424+ <!-- Start Error Handling [errors] -->
425+ ## Error Handling
426+
427+ Handling errors in this SDK should largely match your expectations. All operations return a response object or raise an error.
428+
429+ By default an API error will raise a ` Errors::APIError ` , which has the following properties:
430+
431+ | Property | Type | Description |
432+ | ----------------| -----------------------------------------| -----------------------|
433+ | ` message ` | * string* | The error message |
434+ | ` status_code ` | * int* | The HTTP status code |
435+ | ` raw_response ` | * Faraday::Response* | The raw HTTP response |
436+ | ` body ` | * string* | The response content |
437+
438+ When custom error responses are specified for an operation, the SDK may also throw their associated exception. You can refer to respective * Errors* tables in SDK docs for more details on possible exception types for each operation. For example, the ` delete_account ` method throws the following exceptions:
439+
440+ | Error Type | Status Code | Content Type |
441+ | ------------------------------------------- | ----------- | ---------------- |
442+ | Models::Errors::BadRequestResponse | 400 | application/json |
443+ | Models::Errors::UnauthorizedResponse | 401 | application/json |
444+ | Models::Errors::ForbiddenResponse | 403 | application/json |
445+ | Models::Errors::NotFoundResponse | 404 | application/json |
446+ | Models::Errors::RequestTimedOutResponse | 408 | application/json |
447+ | Models::Errors::ConflictResponse | 409 | application/json |
448+ | Models::Errors::UnprocessableEntityResponse | 422 | application/json |
449+ | Models::Errors::TooManyRequestsResponse | 429 | application/json |
450+ | Models::Errors::InternalServerErrorResponse | 500 | application/json |
451+ | Models::Errors::NotImplementedResponse | 501 | application/json |
452+ | Models::Errors::BadGatewayResponse | 502 | application/json |
453+ | Errors::APIError | 4XX, 5XX | \* /\* |
454+
455+ ### Example
456+
457+ ``` ruby
458+ require ' stackone_client'
459+
460+ s = ::StackOne ::StackOne .new (
461+ security: Models ::Shared ::Security .new (
462+ password: " " ,
463+ username: " " ,
464+ ),
465+ )
466+
467+ begin
468+ res = s.accounts.delete_account(id= " <id>" )
469+
470+ if ! res.linked_account.nil?
471+ # handle response
472+ end
473+ rescue Models ::Errors ::BadRequestResponse => e
474+ # handle $e->$container data
475+ throw $e ;
476+ rescue Models ::Errors ::UnauthorizedResponse => e
477+ # handle $e->$container data
478+ throw $e ;
479+ rescue Models ::Errors ::ForbiddenResponse => e
480+ # handle $e->$container data
481+ throw $e ;
482+ rescue Models ::Errors ::NotFoundResponse => e
483+ # handle $e->$container data
484+ throw $e ;
485+ rescue Models ::Errors ::RequestTimedOutResponse => e
486+ # handle $e->$container data
487+ throw $e ;
488+ rescue Models ::Errors ::ConflictResponse => e
489+ # handle $e->$container data
490+ throw $e ;
491+ rescue Models ::Errors ::UnprocessableEntityResponse => e
492+ # handle $e->$container data
493+ throw $e ;
494+ rescue Models ::Errors ::TooManyRequestsResponse => e
495+ # handle $e->$container data
496+ throw $e ;
497+ rescue Models ::Errors ::InternalServerErrorResponse => e
498+ # handle $e->$container data
499+ throw $e ;
500+ rescue Models ::Errors ::NotImplementedResponse => e
501+ # handle $e->$container data
502+ throw $e ;
503+ rescue Models ::Errors ::BadGatewayResponse => e
504+ # handle $e->$container data
505+ throw $e ;
506+ rescue Errors ::APIError => e
507+ # handle default exception
508+ raise e
509+ end
510+
511+ ```
512+ <!-- End Error Handling [errors] -->
513+
423514<!-- Start Server Selection [server] -->
424515## Server Selection
425516
0 commit comments