Skip to content

Commit

Permalink
MNT: discern FileNotFoundError from other Exceptions
Browse files Browse the repository at this point in the history
  • Loading branch information
tangkong committed Aug 4, 2023
1 parent e4d9699 commit d7a9990
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions typhos/notes.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,10 +98,13 @@ def insert_into_yaml(path: Path, device_name: str, data: dict[str, str]) -> None
try:
with open(path, 'r') as f:
device_notes = yaml.full_load(f)
except Exception as ex:
logger.warning(f'Unable to open existing device info: {ex}.'
'Creating new notes file.')
except FileNotFoundError:
logger.info(f'No existing device notes found at {path}. '
'Creating new notes file.')
device_notes = {}
except Exception as ex:
logger.warning(f'Unable to open existing device notes, aborting: {ex}')
return

device_notes[device_name] = data

Expand Down

0 comments on commit d7a9990

Please sign in to comment.