From c76f1b79b6135300edbf9f6374a7c6438c50a460 Mon Sep 17 00:00:00 2001 From: build-token <build-token> Date: Thu, 15 Jun 2023 12:49:44 +0000 Subject: [PATCH] publish: wip generated from commit 0e8c574d83ecf60699a9e3afe5880d4ffd2c85f0 --- index.js | 34 +++++++++++++++++++++++++++------- package.json | 2 +- 2 files changed, 28 insertions(+), 8 deletions(-) diff --git a/index.js b/index.js index 512e941..1a40a0f 100644 --- a/index.js +++ b/index.js @@ -213,23 +213,25 @@ async function authenticate(login, password, baseUrl, apiAuthKey) { pass: password, }, } + try { const resp = await axios(authRequest) if (resp.data.codeRetour === 100) { return resp.data } else { - Sentry.captureException(JSON.stringify(resp.data)) + const errorMessage = `Authentication failed. Response data: ${JSON.stringify( + resp.data + )}` + Sentry.captureMessage(errorMessage) throw new Error() } } catch (error) { - Sentry.captureException(JSON.stringify(error)) + Sentry.captureException(error) throw new Error(errors.LOGIN_FAILED) } } async function getData(response, baseUrl, apiAuthKey) { - log('debug', 'Start date : ' + startDate) - log('debug', 'End date : ' + endDate) const dataRequest = { method: 'post', url: baseUrl + '/getAllAgregatsByAbonnement.aspx', @@ -255,15 +257,33 @@ async function getData(response, baseUrl, apiAuthKey) { case 100: return format(resp.data) case -2: + Sentry.captureMessage( + `Get data failed. codeRetour - 2. Response data: ${JSON.stringify( + resp.data + )}` + ) throw errors.LOGIN_FAILED case -1: + Sentry.captureMessage( + `Get data failed. codeRetour - 1. Response data: ${JSON.stringify( + resp.data + )}` + ) throw errors.VENDOR_DOWN default: + Sentry.captureMessage( + `Get data failed. Unknown error occurred. Response data: ${JSON.stringify( + resp.data + )}` + ) throw errors.UNKNOWN_ERROR } } catch (error) { - log('debug', 'Error from getAllAgregatsByAbonnement') - throw new Error(errors.VENDOR_DOWN) + if (axios.isAxiosError(error)) { + throw new Error(errors.VENDOR_DOWN) + } + Sentry.captureException(error) + throw error } } @@ -240367,7 +240387,7 @@ var SpanStatus; (function (SpanStatus) { /***/ ((module) => { "use strict"; -module.exports = JSON.parse('{"name":"egl","version":"1.2.1","description":"","repository":{"type":"git","url":"git+https://forge.grandlyon.com/web-et-numerique/llle_project/egl-konnector.git"},"keywords":[],"author":"Grand Lyon","license":"AGPL-3.0","main":"./src/index.js","eslintConfig":{"extends":["cozy-app"]},"eslintIgnore":["build"],"husky":{"hooks":{"pre-commit":"yarn lint"}},"scripts":{"start":"node ./src/index.js","dev":"cozy-konnector-dev","standalone":"cozy-konnector-standalone","pretest":"npm run clean","test":"konitor testit .","check":"konitor check .","clean":"rm -rf ./data","build":"webpack","lint":"eslint --fix .","deploy":"git-directory-deploy --directory build/ --branch ${DEPLOY_BRANCH:-build}","deploy-dev":"git-directory-deploy --directory build/ --branch ${DEPLOY_BRANCH:-build-dev}","cozyPublish":"cozy-app-publish --token $REGISTRY_TOKEN --build-commit $(git rev-parse ${DEPLOY_BRANCH:-build})","travisDeployKey":"./bin/generate_travis_deploy_key"},"dependencies":{"@sentry/node":"7.30.0","@sentry/tracing":"7.30.0","cozy-konnector-libs":"4.56.4","moment":"^2.24.0","moment-timezone":"^0.5.26","axios":"1.2.2"},"devDependencies":{"@types/moment-timezone":"^0.5.30","copy-webpack-plugin":"6.1.1","cozy-app-publish":"0.25.0","cozy-jobs-cli":"1.20.2","cozy-konnector-build":"1.5.1","eslint":"5.16.0","eslint-config-cozy-app":"1.6.0","eslint-plugin-prettier":"3.0.1","git-directory-deploy":"1.5.1","husky":"4.3.0","konitor":"0.10.2","standard-version":"^9.5.0","svgo":"1.3.2","webpack":"5.75.0","webpack-cli":"5.0.1"}}'); +module.exports = JSON.parse('{"name":"egl","version":"1.2.1","description":"","repository":{"type":"git","url":"git+https://forge.grandlyon.com/web-et-numerique/llle_project/egl-konnector.git"},"keywords":[],"author":"Grand Lyon","license":"AGPL-3.0","main":"./src/index.js","eslintConfig":{"extends":["cozy-app"]},"eslintIgnore":["build"],"husky":{"hooks":{"pre-commit":"yarn lint"}},"scripts":{"start":"node ./src/index.js","dev":"cozy-konnector-dev","standalone":"cozy-konnector-standalone","pretest":"npm run clean","test":"konitor testit .","check":"konitor check .","clean":"rm -rf ./data","build":"webpack","lint":"eslint --fix .","deploy":"git-directory-deploy --directory build/ --branch ${DEPLOY_BRANCH:-build}","deploy-dev":"git-directory-deploy --directory build/ --branch ${DEPLOY_BRANCH:-build-dev}","cozyPublish":"cozy-app-publish --token $REGISTRY_TOKEN --build-commit $(git rev-parse ${DEPLOY_BRANCH:-build})","travisDeployKey":"./bin/generate_travis_deploy_key"},"dependencies":{"@sentry/node":"7.30.0","@sentry/tracing":"7.30.0","cozy-konnector-libs":"4.56.4","moment":"^2.24.0","moment-timezone":"^0.5.26","axios":"1.2.2"},"devDependencies":{"@types/moment-timezone":"^0.5.30","copy-webpack-plugin":"6.1.1","cozy-app-publish":"0.25.0","cozy-jobs-cli":"1.20.2","cozy-konnector-build":"1.4.4","eslint":"5.16.0","eslint-config-cozy-app":"1.6.0","eslint-plugin-prettier":"3.0.1","git-directory-deploy":"1.5.1","husky":"4.3.0","konitor":"0.10.2","standard-version":"^9.5.0","svgo":"1.3.2","webpack":"5.75.0","webpack-cli":"5.0.1"}}'); /***/ }), /* 1647 */ diff --git a/package.json b/package.json index d6bea2b..5c19bf3 100644 --- a/package.json +++ b/package.json @@ -51,7 +51,7 @@ "copy-webpack-plugin": "6.1.1", "cozy-app-publish": "0.25.0", "cozy-jobs-cli": "1.20.2", - "cozy-konnector-build": "1.5.1", + "cozy-konnector-build": "1.4.4", "eslint": "5.16.0", "eslint-config-cozy-app": "1.6.0", "eslint-plugin-prettier": "3.0.1", -- GitLab