Closed flit closed 3 years ago
Hi Chris, good point - I will look at at it and add detection of unsupported systems.
I keep it as exception (but better handled), for the PyOCD purposes this is fixed (by you :-) )in pyocd-pemicro package, that is correct.
In this package the exception MUST be raised.
Thank you Petr
I agree the exception should still be raised. Can you please raise a specific exception class for this error? Having pyocd-pemicro look for a particular string in the error message is a very bad way of handling this, but is currently the only option.
Instead of always using the generic PEMicroException
class, I recommend creating these exception subclasses:
PEMicroUnknownOSError
PEMicroLibraryLoadError
PEMicroNoConnectionError
PEMicroConnectFailure
Also, for some errors within the methods of PyPemicro
, regular Python exceptions should be raised. Like in PyPemicro.read_block()
, you should raise ValueError
if parameters are invalid.
You can probably also use asserts for verifying invariants of methods, such as requiring the library to be loaded and a valid connection, instead of raising exceptions. (This is always a difficult design decision. 😄 )
The error below is raised from
pyocd list -vv
when running on an Apple M1 MacBook Air.Pypemicro needs to gracefully handle situations where it's run on a system for which it does not have a valid library. Or at least raise a distinct
PEMicroUnsupportedArchitecture
exception so that pyocd-pemicro can catch and gracefully handle it.