From 3da963b3b92d09d6ba15becadf650d11452bdfaf Mon Sep 17 00:00:00 2001 From: Emily Cutlip <4525370+NotGyro@users.noreply.github.com> Date: Tue, 20 Feb 2024 13:22:39 -0500 Subject: [PATCH] Rename ErrorReportable::report() to unwrap_or_report() --- pgrx-pg-sys/src/submodules/panic.rs | 8 ++++---- pgrx-sql-entity-graph/src/pg_extern/mod.rs | 2 +- pgrx/src/datum/into.rs | 2 +- pgrx/src/spi/tuple.rs | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/pgrx-pg-sys/src/submodules/panic.rs b/pgrx-pg-sys/src/submodules/panic.rs index 7dd0f7d58..0a621bd61 100644 --- a/pgrx-pg-sys/src/submodules/panic.rs +++ b/pgrx-pg-sys/src/submodules/panic.rs @@ -28,7 +28,7 @@ pub trait ErrorReportable { type Inner; /// Raise a Postgres ERROR if appropriate, otherwise return a value - fn report(self) -> Self::Inner; + fn unwrap_or_report(self) -> Self::Inner; } impl ErrorReportable for Result @@ -42,7 +42,7 @@ where /// If this [`Result`] represents the `Err` variant, raise it as an error. If it happens to /// be an [`ErrorReport`], then that is specifically raised. Otherwise it's just a general /// [`ereport!`] as a [`PgLogLevel::ERROR`]. - fn report(self) -> Self::Inner { + fn unwrap_or_report(self) -> Self::Inner { self.unwrap_or_else(|e| { let any: Box<&dyn Any> = Box::new(&e); if any.downcast_ref::().is_some() { @@ -235,7 +235,7 @@ impl ErrorReportWithLevel { impl ErrorReport { /// Create an [ErrorReport] which can be raised via Rust's [std::panic::panic_any()] or as - /// a specific Postgres "ereport()` level via [ErrorReport::report(self, PgLogLevel)] + /// a specific Postgres "ereport()` level via [ErrorReport::unwrap_or_report(self, PgLogLevel)] /// /// Embedded "file:line:col" location information is taken from the caller's location #[track_caller] @@ -251,7 +251,7 @@ impl ErrorReport { } /// Create an [ErrorReport] which can be raised via Rust's [std::panic::panic_any()] or as - /// a specific Postgres "ereport()` level via [ErrorReport::report(self, PgLogLevel)]. + /// a specific Postgres "ereport()` level via [ErrorReport::unwrap_or_report(self, PgLogLevel)]. /// /// For internal use only fn with_location>( diff --git a/pgrx-sql-entity-graph/src/pg_extern/mod.rs b/pgrx-sql-entity-graph/src/pg_extern/mod.rs index a57b2b2ea..36e80251d 100644 --- a/pgrx-sql-entity-graph/src/pg_extern/mod.rs +++ b/pgrx-sql-entity-graph/src/pg_extern/mod.rs @@ -439,7 +439,7 @@ impl PgExtern { let mut ret_expr = quote! { #func_name(#(#arg_pats),*) }; if result { // If it's a result, we need to report it. - ret_expr = quote! { #ret_expr.report() }; + ret_expr = quote! { #ret_expr.unwrap_or_report() }; } if !optional { // If it's not already an option, we need to wrap it. diff --git a/pgrx/src/datum/into.rs b/pgrx/src/datum/into.rs index b74992b03..c2f841e95 100644 --- a/pgrx/src/datum/into.rs +++ b/pgrx/src/datum/into.rs @@ -107,7 +107,7 @@ where /// [`ERRCODE_DATA_EXCEPTION`]: pg_sys::errcodes::PgSqlErrorCode::ERRCODE_DATA_EXCEPTION #[inline] fn into_datum(self) -> Option { - self.report().into_datum() + self.unwrap_or_report().into_datum() } #[inline] diff --git a/pgrx/src/spi/tuple.rs b/pgrx/src/spi/tuple.rs index 8e641bf6d..63c198a2e 100644 --- a/pgrx/src/spi/tuple.rs +++ b/pgrx/src/spi/tuple.rs @@ -288,7 +288,7 @@ impl<'conn> Iterator for SpiTupleTable<'conn> { None } else { assert!(self.current >= 0); - self.get_heap_tuple().report() + self.get_heap_tuple().unwrap_or_report() } }