소스 검색

Merge pull request #5957 from Gu1nness/5734-1.1-maint

Use an exception catching to avoid a stack trace
TW 3 년 전
부모
커밋
abbc8a6cb9
1개의 변경된 파일6개의 추가작업 그리고 2개의 파일을 삭제
  1. 6 2
      src/borg/patterns.py

+ 6 - 2
src/borg/patterns.py

@@ -9,6 +9,7 @@ from enum import Enum
 
 from . import shellpattern
 from .helpers import clean_lines
+from .helpers import Error
 
 
 def parse_patternfile_line(line, roots, ie_commands, fallback):
@@ -53,8 +54,11 @@ class ArgparsePatternFileAction(argparse.Action):
         Lines empty or starting with '#' after stripping whitespace on both line ends are ignored.
         """
         filename = values[0]
-        with open(filename) as f:
-            self.parse(f, args)
+        try:
+            with open(filename) as f:
+                self.parse(f, args)
+        except FileNotFoundError as e:
+            raise Error(str(e))
 
     def parse(self, fobj, args):
         load_pattern_file(fobj, args.paths, args.patterns)