Skip to content

Commit

Permalink
Merge pull request #5957 from Gu1nness/5734-1.1-maint
Browse files Browse the repository at this point in the history
Use an exception catching to avoid a stack trace
  • Loading branch information
ThomasWaldmann authored Aug 14, 2021
2 parents f3db40c + c12fc71 commit abbc8a6
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/borg/patterns.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

from . import shellpattern
from .helpers import clean_lines
from .helpers import Error


def parse_patternfile_line(line, roots, ie_commands, fallback):
Expand Down Expand Up @@ -53,8 +54,11 @@ def __call__(self, parser, args, values, option_string=None):
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)
Expand Down

0 comments on commit abbc8a6

Please sign in to comment.