Skip to content

Return an more explicit error if the client is not authorized to send a request #112

Description

@szank

Hi,
Could you please consider returning a more descriptive error when the account making an API request is not authorised to perform it.
For example if you want to list the queues via rabbithole API and there is a typo in the password/the permissions on RabbitMQ are not set correctly the error one would get is:
json: cannot unmarshal object into Go value of type []rabbithole.QueueInfo. This can be somewhat confusing.

When using curl the retrieved response is:

< HTTP/1.1 401 Unauthorized
< content-length: 50
< content-type: application/json
< date: Fri, 13 Apr 2018 13:31:57 GMT
< server: Cowboy
< vary: origin
<
* Connection #0 to host 127.0.0.1 left intact
{"error":"not_authorised","reason":"Login failed"}

I would suggest returning an "unauthorised" error message if the query response code is 401 on every request.

I am happy to create the PR, but right now I am quite pressed for time, so it would have to wait.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions