Skip to content

Commit

Permalink
fix: throw error to not stuck the process (#108)
Browse files Browse the repository at this point in the history
  • Loading branch information
kobenguyent authored Dec 19, 2023
1 parent e2e26b3 commit d1614b0
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions lib/testrail.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ class TestRail {
} catch (error) {
const parsedError = error && error.response && error.response.data ? error.response.data.error : error;
output.error(`getCases: ERROR - cannot get results for projectId:${projectId} due to ${parsedError}`);
throw Error(parsedError);
}
}

Expand All @@ -66,6 +67,7 @@ class TestRail {
const parsedError = error && error.response && error.response.data ? error.response.data.error : error;
output.error(`addPlan: ERROR - cannot add plan to projectId:${projectId} due to ${parsedError}`);
output.error(`addPlan: ERROR - request data was ${JSON.stringify(data)}`);
throw Error(parsedError);
}
}

Expand All @@ -79,6 +81,7 @@ class TestRail {
const parsedError = error && error.response && error.response.data ? error.response.data.error : error;
output.error(`addPlanEntry: ERROR - cannot add plan entry to planId:${planId} due to ${parsedError}`);
output.error(`addPlanEntry: ERROR - request data was ${JSON.stringify(data)}`);
throw Error(parsedError);
}
}

Expand All @@ -90,6 +93,7 @@ class TestRail {
} catch (error) {
const parsedError = error && error.response && error.response.data ? error.response.data.error : error;
output.error(`getSuites: ERROR - cannot get suites for projectId:${projectId} due to ${parsedError}`);
throw Error(parsedError);
}
}

Expand All @@ -101,6 +105,7 @@ class TestRail {
} catch (error) {
const parsedError = error && error.response && error.response.data ? error.response.data.error : error;
output.error(`getConfigs: ERROR - cannot get configs for projectId:${projectId} due to ${parsedError}`);
throw Error(parsedError);
}
}

Expand All @@ -114,6 +119,7 @@ class TestRail {
const parsedError = error && error.response && error.response.data ? error.response.data.error : error;
output.error(`addRun: ERROR - cannot add run to projectId:${projectId} due to ${parsedError}`);
output.error(`addRun: ERROR - request data was ${JSON.stringify(data)}`);
throw Error(parsedError);
}
}

Expand All @@ -127,6 +133,7 @@ class TestRail {
const parsedError = error && error.response && error.response.data ? error.response.data.error : error;
output.error(`updateRun: ERROR - cannot update run for runId:${runId} due to ${parsedError}`);
output.error(`updateRun: ERROR - request data was ${JSON.stringify(data)}`);
throw Error(parsedError);
}
}

Expand All @@ -139,6 +146,7 @@ class TestRail {
} catch (error) {
const parsedError = error && error.response && error.response.data ? error.response.data.error : error;
output.error(`updateRun: ERROR - cannot get run for runId:${runId} due to ${parsedError}`);
throw Error(parsedError);
}
}

Expand All @@ -149,6 +157,7 @@ class TestRail {
}).catch(error => {
const parsedError = error && error.response && error.response.data ? error.response.data.error : error;
output.error(`getResultsForCase: ERROR - cannot get results for caseId:${caseId} on runId:${runId} due to ${parsedError}`);
throw Error(parsedError);
});
}

Expand All @@ -161,6 +170,7 @@ class TestRail {
const parsedError = error && error.response && error.response.data ? error.response.data.error : error;
output.error(`addResultsForCases: ERROR - cannot add result for case due to ${parsedError}`);
output.error(`addResultsForCases: ERROR - request data was ${JSON.stringify(data)}`);
throw Error(parsedError);
});
}

Expand All @@ -177,6 +187,7 @@ class TestRail {
const parsedError = error && error.response && error.response.data ? error.response.data.error : error;
output.error(`addAttachmentToResult: ERROR - cannot add attachment due to ${parsedError}`);
output.error(`addAttachmentToResult: ERROR - request data was ${JSON.stringify(form)}`);
throw Error(parsedError);
});
}

Expand All @@ -187,6 +198,7 @@ class TestRail {
}).catch(error => {
const parsedError = error && error.response && error.response.data ? error.response.data.error : error;
output.error(`close run ${runId}: ERROR - cannot close run due to ${parsedError}`);
throw Error(parsedError);
});
}
}
Expand Down

0 comments on commit d1614b0

Please sign in to comment.