From 5948a38c812ab1d4d3713beb28c5509f26c48eb2 Mon Sep 17 00:00:00 2001 From: Dmitrii Gridnev Date: Tue, 26 Nov 2024 13:30:14 +0100 Subject: [PATCH] fix: error handling for HTTP status 422 Added error handling for HTTP status 422 in API responses, returning a descriptive QaseError with relevant details. --- qase-javascript-commons/changelog.md | 6 ++++++ qase-javascript-commons/package.json | 2 +- qase-javascript-commons/src/reporters/testops-reporter.ts | 2 +- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/qase-javascript-commons/changelog.md b/qase-javascript-commons/changelog.md index a1231a1c..ea144bd2 100644 --- a/qase-javascript-commons/changelog.md +++ b/qase-javascript-commons/changelog.md @@ -2,6 +2,12 @@ ## What's new +Added error handling for HTTP status 422 in API responses, returning a descriptive QaseError with relevant details. + +# qase-javascript-commons@2.2.5 + +## What's new + Use the API v2 client by default. If you want to use the API v1 client, specify the `useV2` option in the config file or the environment variable `QASE_TESTOPS_USEV2` as `False`. diff --git a/qase-javascript-commons/package.json b/qase-javascript-commons/package.json index 3043a984..2fa063e9 100644 --- a/qase-javascript-commons/package.json +++ b/qase-javascript-commons/package.json @@ -1,6 +1,6 @@ { "name": "qase-javascript-commons", - "version": "2.2.5", + "version": "2.2.6", "description": "Qase JS Reporters", "main": "./dist/index.js", "types": "./dist/index.d.ts", diff --git a/qase-javascript-commons/src/reporters/testops-reporter.ts b/qase-javascript-commons/src/reporters/testops-reporter.ts index 291e7cd8..092efd6e 100644 --- a/qase-javascript-commons/src/reporters/testops-reporter.ts +++ b/qase-javascript-commons/src/reporters/testops-reporter.ts @@ -791,7 +791,7 @@ export class TestOpsReporter extends AbstractReporter { return new QaseError(message + ': Not found.'); } - if (error.response?.status === 400) { + if (error.response?.status === 400 || error.response?.status === 422) { return new QaseError(message + ': Bad request. Body: \n ' + JSON.stringify(model)); }