Skip to content

Improve the error message when the request fails #63

Closed
@jgauffin

Description

@jgauffin

Can you add the response content to the exception message?
It will help immensely when getting started.

In HandleResponse:

// you might want to have a try/catch, there are cases when reading
// the content fails (although it should work in most cases)
var str = response.Content.ReadAsStringAsync().GetAwaiter().GetResult();
throw new WebPushException($"{message}. Details: {str}", response.StatusCode, response.Headers, subscription);

Before

WebPush.WebPushException: 'Received unexpected response code: 403'

After

WebPush.WebPushException: 'Received unexpected response code: 403. Details: the key in the authorization header does not correspond to the sender ID used to subscribe this user. Please ensure you are using the correct sender ID and server Key from the Firebase console.

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