From fb758c33d11a77b9f44a98aab6853b1be799644d Mon Sep 17 00:00:00 2001 From: Esteban Borai Date: Thu, 5 Nov 2020 18:28:00 -0300 Subject: [PATCH] feat: send XMLHttpRequest as second param for onError 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. --- src/index.d.ts | 2 +- src/js/pdf.js | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/index.d.ts b/src/index.d.ts index e5e9449..d52f589 100644 --- a/src/index.d.ts +++ b/src/index.d.ts @@ -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; diff --git a/src/js/pdf.js b/src/js/pdf.js index 7e06324..c4c5d72 100644 --- a/src/js/pdf.js +++ b/src/js/pdf.js @@ -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 }) @@ -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