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

Add response to the WebDAVClientError type #262

Merged
merged 5 commits into from
May 21, 2021

Conversation

dpakach
Copy link
Contributor

@dpakach dpakach commented May 13, 2021

Add response property to WebDAVClientError type.

the error handleing is no longer handled by axios (https://github.com/perry-mitchell/webdav-client/blob/master/source/request.ts#L52) so the error object doesn't has access to the HTTP response. this PR fixes that.

@@ -7,6 +8,7 @@ export function handleResponseCode(context: WebDAVClientContext, response: Respo
if (status >= 400) {
const err: WebDAVClientError = new Error(`Invalid response: ${status} ${response.statusText}`) as WebDAVClientError;
err.status = status;
err.response = response as AxiosResponse;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd prefer not to expose Axios-specific properties outside of this library, as I can't guarantee that I'll always use Axios as the request client. Would you consider changing this to err.response = response (only) and using the Response type in the WebDAVClientError interface?

@dpakach
Copy link
Contributor Author

dpakach commented May 18, 2021

@perry-mitchell I've fixed it. Please have a look.

@dpakach dpakach requested a review from perry-mitchell May 18, 2021 03:21
@perry-mitchell perry-mitchell merged commit a3af7d7 into perry-mitchell:master May 21, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants