-
-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #150 from supabase/chore/stripe-fdw-error
chore(stripe_fdw): refactor error reporting
- Loading branch information
Showing
3 changed files
with
171 additions
and
186 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,41 @@ | ||
#![allow(clippy::module_inception)] | ||
mod stripe_fdw; | ||
mod tests; | ||
|
||
use pgrx::pg_sys::panic::ErrorReport; | ||
use pgrx::prelude::PgSqlErrorCode; | ||
use thiserror::Error; | ||
|
||
use supabase_wrappers::prelude::{CreateRuntimeError, OptionsError}; | ||
|
||
#[derive(Error, Debug)] | ||
enum StripeFdwError { | ||
#[error("column '{0}' data type is not supported")] | ||
UnsupportedColumnType(String), | ||
|
||
#[error("Stripe object '{0}' not implemented")] | ||
ObjectNotImplemented(String), | ||
|
||
#[error("{0}")] | ||
OptionsError(#[from] OptionsError), | ||
|
||
#[error("{0}")] | ||
CreateRuntimeError(#[from] CreateRuntimeError), | ||
|
||
#[error("parse url failed: {0}")] | ||
UrlParseError(#[from] url::ParseError), | ||
|
||
#[error("request failed: {0}")] | ||
RequestError(#[from] reqwest_middleware::Error), | ||
|
||
#[error("parse JSON response failed: {0}")] | ||
JsonParseError(#[from] serde_json::Error), | ||
} | ||
|
||
impl From<StripeFdwError> for ErrorReport { | ||
fn from(value: StripeFdwError) -> Self { | ||
ErrorReport::new(PgSqlErrorCode::ERRCODE_FDW_ERROR, format!("{value}"), "") | ||
} | ||
} | ||
|
||
type StripeFdwResult<T> = Result<T, StripeFdwError>; |
Oops, something went wrong.