You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Typed exception hierarchy instead of bare Exception #47
A caller cannot distinguish an OSHConnect failure from a bug in its own code — except Exception is the only option, and it catches KeyError, AttributeError, and everything else along with it. Downstream code that wants "retry on server rejection, crash on programming error" has no way to express it.
Reproduce
try:
system.insert_self()
exceptExceptionase: # the only thing that works today
... # also catches the KeyError from #44
There is no oshconnect.exceptions module to import from.
Possible fix
Add src/oshconnect/exceptions.py with a small hierarchy, all rooted at a base subclassing Exception so existing except Exception: callers are unaffected:
OSHConnectError(Exception)
├── ResourceInsertError # non-ok response to a create POST
│ └── carries .status_code, .response_text, .resource_type
└── ConfigurationError # e.g. unregistered node (#43)
Convert the five sites above, and export the names from oshconnect/__init__.py. Message text should stay as-is — the current messages already carry status code and body, which is the useful part.
Blocks nothing, but #43 and #44 both want to raise something and should land after this so they use the typed form.
Activity