Skip to content

Construct useful error objects/messages from unexpected response codes and errors #46

Open
@kshepherd

Description

@kshepherd

In fetch_resource and elsewhere, errors are handled in a pretty negligent way - a line is logged and None is returned, and things carry on...
But this does not allow the calling script to inspect what kind of error was encountered and what it needs to do to remedy / retry the failed fetch / search / whatever.

I think several things need to be improved:

  1. Look at the best way to model either Error objects or using Python exceptions, based on the error message like
{"timestamp":"2025-01-30T00:31:17.885+00:00",
"status":500,
"error":"Internal Server Error",
"message":"Unexpected error of some kind....",
"path":"/server/api/discover/search/objects"}
  1. Architecturally, change fetch_resource and all the calling functions to stop catching+logging, but either returning these Error objects somehow or raising new Exceptions based on the error thrown by fetch_resource so the caller can handle them

This would be a breaking change as most existing scripts using the library would be used to testing for None returns and reading log messages for error handling

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions