StripeKit 0.1.1
Stripe integration toolkit for C++
Loading...
Searching...
No Matches
stripekit::StripeApiException Class Reference

Thrown when Stripe rejects a request, or cannot be reached. More...

#include <Errors.h>

Inheritance diagram for stripekit::StripeApiException:
[legend]

Public Member Functions

 StripeApiException (StripeErrorPayload payload)
 Creates an API exception from Stripe's error details.
const StripeErrorPayload & payload () const noexcept
 Returns the details Stripe gave for the failure.
bool retryable () const noexcept
 Returns whether trying the same request again may succeed.
Public Member Functions inherited from stripekit::StripeKitException
 StripeKitException (const std::string &message)
 Creates an exception carrying a descriptive message.
 ~StripeKitException () override
 Destroys the exception instance.

Detailed Description

Thrown when Stripe rejects a request, or cannot be reached.

try {
const auto session = co_await stripe->checkout().sessions().create_async(request);
} catch (const stripekit::StripeApiException& error) {
log_error(error.payload().message, error.payload().request_id);
}
Thrown when Stripe rejects a request, or cannot be reached.
Definition Errors.h:98
const StripeErrorPayload & payload() const noexcept
Returns the details Stripe gave for the failure.
std::string message
Stripe's human-readable description of the failure.
Definition Errors.h:54
std::string request_id
Id of the failed request in Stripe's logs, of the form "req_...".
Definition Errors.h:60

Definition at line 98 of file Errors.h.

Constructor & Destructor Documentation

◆ StripeApiException()

stripekit::StripeApiException::StripeApiException ( StripeErrorPayload payload)
explicit

Creates an API exception from Stripe's error details.

Parameters
payloadThe parsed error details.

Member Function Documentation

◆ payload()

const StripeErrorPayload & stripekit::StripeApiException::payload ( ) const
noexcept

Returns the details Stripe gave for the failure.

Returns
A reference valid for the lifetime of the exception.

◆ retryable()

bool stripekit::StripeApiException::retryable ( ) const
noexcept

Returns whether trying the same request again may succeed.

Returns
True for transient failures such as rate limits and connection problems; false for anything that will fail the same way again.

The documentation for this class was generated from the following file: