cms-gem-daq-project / gem-plotting-tools

Repository for GEM commissioning plotting tools
GNU General Public License v3.0
1 stars 26 forks source link

getDirByAnaType raises KeyError for bad anaType #243

Closed bdorney closed 4 years ago

bdorney commented 5 years ago

Description

Function getDirByAnaType() will no longer exit if input argument anaType is not in list of accepted types (ana_config) but will instead raise a KeyError which can be caught as an exception.

Types of changes

Breaking because instead of exiting it will raise an error.

Motivation and Context

QOL; allow developers opportunity to catch bad anaType and handle this instead of automatically exiting.

How Has This Been Tested?

Change was trivial.

Screenshots (if appropriate):

Checklist:

jsturdy commented 5 years ago

Is there an example where this functionality will be beneficial (catching rather than simply exiting)?

bdorney commented 5 years ago

Is there an example where this functionality will be beneficial (catching rather than simply exiting)?

Off the top of my head no. But I think in general it might be better coding practice to generate an exception in an API function then exit in an manner that does not raise a SystemExit exception. Especially as new developers come in and may not be familiar with the API...it may be difficult for them to trace down what's going on and raising an exception will ensure a stack trace.

lpetre-ulb commented 4 years ago

Should this PR be merged or closed? The change seems trivial, but the PR require a rebase and a small change.