Skip to content

Commit

Permalink
feat: send XMLHttpRequest as second param for onError
Browse files Browse the repository at this point in the history
Currently the `onError` callback only has the `req.statusText` field,
as param.

Would be useful to have the XMLHttpRequest object instance along
with the req.statusText, so we are able to consume all the details
from the request, the response (ArrayBuffer) for instance.

When available the XMLHttpRequest instance used in the request
is sent as second param for the `onError` callback.
  • Loading branch information
EstebanBorai committed Nov 5, 2020
1 parent c31460b commit fb758c3
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ declare namespace printJS {
css?: string | string[];
style?: string;
scanStyles?: boolean;
onError?: (error: any) => void;
onError?: (error: any, xmlHttpRequest?: XMLHttpRequest) => void;
onPrintDialogClose?: () => void;
onIncompatibleBrowser?: () => void;
base64?: boolean;
Expand Down
4 changes: 2 additions & 2 deletions src/js/pdf.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export default {

req.addEventListener('error', () => {
cleanUp(params)
params.onError(req.statusText)
params.onError(req.statusText, req)

// Since we don't have a pdf document available, we will stop the print job
})
Expand All @@ -30,7 +30,7 @@ export default {
// Check for errors
if ([200, 201].indexOf(req.status) === -1) {
cleanUp(params)
params.onError(req.statusText)
params.onError(req.statusText, req)

// Since we don't have a pdf document available, we will stop the print job
return
Expand Down

0 comments on commit fb758c3

Please sign in to comment.