[librsvg: 8/10] CHandle: turn explicit panics into g_critical



commit 38611a48453fe8bfe6b7f8f4f345bdf797df591c
Author: Federico Mena Quintero <federico gnome org>
Date:   Tue Jul 23 15:58:08 2019 -0500

    CHandle: turn explicit panics into g_critical

 rsvg_internals/src/c_api.rs | 17 +++++++++++++----
 1 file changed, 13 insertions(+), 4 deletions(-)
---
diff --git a/rsvg_internals/src/c_api.rs b/rsvg_internals/src/c_api.rs
index d55c97f7..cdacbb9c 100644
--- a/rsvg_internals/src/c_api.rs
+++ b/rsvg_internals/src/c_api.rs
@@ -483,7 +483,12 @@ impl CHandle {
 
         match *state {
             LoadState::Start => (),
-            _ => panic!("Please set the base file or URI before loading any data into RsvgHandle",),
+            _ => {
+                rsvg_g_critical(
+                    "Please set the base file or URI before loading any data into RsvgHandle",
+                );
+                return;
+            }
         }
 
         match Url::parse(&url) {
@@ -551,7 +556,10 @@ impl CHandle {
                 buffer.extend_from_slice(buf);
             }
 
-            _ => panic!("Handle must not be closed in order to write to it"),
+            _ => {
+                rsvg_g_critical("Handle must not be closed in order to write to it");
+                return;
+            }
         }
     }
 
@@ -587,10 +595,11 @@ impl CHandle {
         match *state {
             LoadState::Start => self.read_stream(state, stream, cancellable),
             LoadState::Loading { .. } | LoadState::ClosedOk { .. } | LoadState::ClosedError => {
-                panic!(
+                rsvg_g_critical(
                     "handle must not be already loaded in order to call \
                      rsvg_handle_read_stream_sync()",
-                )
+                );
+                Err(LoadingError::Unknown)
             }
         }
     }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]