Ver código fonte

Merge pull request #7886 from ThomasWaldmann/fix-inv-pattern-errorhandling-1.2

Fix arg parsing error handling (1.2-maint)
TW 1 ano atrás
pai
commit
4a8f8bf789
2 arquivos alterados com 12 adições e 1 exclusões
  1. 11 0
      src/borg/archiver.py
  2. 1 1
      src/borg/patterns.py

+ 11 - 0
src/borg/archiver.py

@@ -5325,6 +5325,17 @@ def main():  # pragma: no cover
             if tb_log_level == logging.ERROR:
                 print(tb, file=sys.stderr)
             sys.exit(e.exit_code)
+        except argparse.ArgumentTypeError as e:
+            # we might not have logging setup yet, so get out quickly
+            print(str(e), file=sys.stderr)
+            sys.exit(EXIT_ERROR)
+        except Exception:
+            msg = 'Local Exception'
+            tb = f'{traceback.format_exc()}\n{sysinfo()}'
+            # we might not have logging setup yet, so get out quickly
+            print(msg, file=sys.stderr)
+            print(tb, file=sys.stderr)
+            sys.exit(EXIT_ERROR)
         try:
             with sig_int:
                 exit_code = archiver.run(args)

+ 1 - 1
src/borg/patterns.py

@@ -381,7 +381,7 @@ def parse_inclexcl_command(cmd_line_str, fallback=ShellPattern):
 
     cmd = cmd_prefix_map.get(cmd_line_str[0])
     if cmd is None:
-        raise argparse.ArgumentTypeError("A pattern/command must start with anyone of: %s" %
+        raise argparse.ArgumentTypeError("A pattern/command must start with any of: %s" %
                                          ', '.join(cmd_prefix_map))
 
     # remaining text on command-line following the command character