Skip to content

Why return value on error rather than raise exception? #15

@azzamsa

Description

@azzamsa

why don't raise value immediately in requestor.py if the request didn't return successful result? instead of checking it manually (by the user of this library manually) ?

response.status_code == 200:
            try:
                return response.json()
            except ValueError:
                # GET /system/version
                return response.text
        else:
            return {    # <------ why not raise exception?
                'reason': response.reason,
                'status_code': response.status_code,
                'url': response.request.url
            }

why not raise ValueError("eror ...") ? so that the user know something wrong happened.

With current design we need to check every time if the response contains 'status_code' or not.

Thanks for admin-api.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions