[gjs: 3/6] jsapi-util-error: Use switch to filter the supported error protos




commit 1df6a2ba5634f6c3bc3fa2984a506b55465d1698
Author: Marco Trevisan (TreviƱo) <mail 3v1n0 net>
Date:   Tue Sep 8 17:51:44 2020 +0200

    jsapi-util-error: Use switch to filter the supported error protos

 gjs/jsapi-util-error.cpp | 19 ++++++++++++++-----
 1 file changed, 14 insertions(+), 5 deletions(-)
---
diff --git a/gjs/jsapi-util-error.cpp b/gjs/jsapi-util-error.cpp
index 94c111150..8cb90bad2 100644
--- a/gjs/jsapi-util-error.cpp
+++ b/gjs/jsapi-util-error.cpp
@@ -157,11 +157,20 @@ gjs_throw_custom(JSContext  *cx,
                  ...)
 {
     va_list args;
-    g_return_if_fail(kind == JSProto_Error || kind == JSProto_InternalError ||
-                     kind == JSProto_EvalError || kind == JSProto_RangeError ||
-                     kind == JSProto_ReferenceError ||
-                     kind == JSProto_SyntaxError || kind == JSProto_TypeError ||
-                     kind == JSProto_URIError);
+
+    switch (kind) {
+        case JSProto_Error:
+        case JSProto_EvalError:
+        case JSProto_InternalError:
+        case JSProto_RangeError:
+        case JSProto_ReferenceError:
+        case JSProto_SyntaxError:
+        case JSProto_TypeError:
+        case JSProto_URIError:
+            break;
+        default:
+            g_return_if_reached();
+    }
 
     va_start(args, format);
     gjs_throw_valist(cx, kind, error_name, format, args);


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