Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve error message logging when error response contain json #208

Open
andebor opened this issue Mar 8, 2023 · 1 comment
Open

Improve error message logging when error response contain json #208

andebor opened this issue Mar 8, 2023 · 1 comment

Comments

@andebor
Copy link
Contributor

andebor commented Mar 8, 2023

We currently treat all http error messages as strings when storing them. Several of the responses are actually json. This results in strings with escaped json. This doesn't have the best readability.
I suggest that we check the response for json before passing on the response. If it's json, we pass a long the object instead. (Might want to append i.e. the status code before passing it along.)

Instead of this:

{
  "id": "wpm78z4e45",
  "title": "TEST-owner-anders-dev-export",
  "start": "2023-03-08T15:29:59.092614+01:00",
  "end": "2023-03-08T15:30:01.080508+01:00",
  "lastError": "Received http sink error (401): {\"message\":\"code=400, message=missing or malformed jwt\"}\n"
}

Do something like this:

{
  "id": "wpm78z4e45",
  "title": "TEST-owner-anders-dev-export",
  "start": "2023-03-08T15:29:59.092614+01:00",
  "end": "2023-03-08T15:30:01.080508+01:00",
  "lastError": {
    "body": {
      "message": "code=400, message=missing or malformed jwt"
    },
    "title": "Received http sink error (401)",
    "statusCode": 401
  }
}

If the error doesn't contain json, it should use the old behavior.

@andebor
Copy link
Contributor Author

andebor commented Mar 10, 2023

I guess an option would be to do this on the client side. I'm not sure what we prefer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant