From f7e84f0a09d5c5dc964c68d39bc396e4b4e4ae46 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mike=20F=C3=A4hrmann?= Date: Mon, 14 Jul 2025 21:32:56 +0200 Subject: [PATCH] [actions] add 'raise' action --- gallery_dl/actions.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/gallery_dl/actions.py b/gallery_dl/actions.py index 6bcebac9..4733dd51 100644 --- a/gallery_dl/actions.py +++ b/gallery_dl/actions.py @@ -192,6 +192,24 @@ def action_flag(opts): return _flag, None +def action_raise(opts): + name, _, arg = opts.partition(" ") + + exc = getattr(exception, name, None) + if exc is None: + import builtins + exc = getattr(builtins, name, Exception) + + if arg: + def _raise(args): + raise exc(arg) + else: + def _raise(args): + raise exc() + + return None, _raise + + def action_abort(opts): return None, util.raises(exception.StopExtraction) @@ -222,6 +240,7 @@ ACTIONS = { "flag" : action_flag, "level" : action_level, "print" : action_print, + "raise" : action_raise, "restart" : action_restart, "status" : action_status, "terminate": action_terminate,