Wrap request promise in try catch

This commit is contained in:
Thomas Hu
2020-07-17 11:57:18 -04:00
parent e16d515d3b
commit 8ddda09c14
5 changed files with 217 additions and 205 deletions

View File

@@ -1,6 +1,6 @@
MIT License MIT License
Copyright (c) 2019 Codecov Copyright (c) 2019-2020 Codecov
Permission is hereby granted, free of charge, to any person obtaining a copy Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal of this software and associated documentation files (the "Software"), to deal

6
dist/index.js vendored
View File

@@ -2236,6 +2236,7 @@ try {
url: "https://codecov.io/bash", url: "https://codecov.io/bash",
json: false json: false
}, (error, response, body) => { }, (error, response, body) => {
try {
if (error && fail_ci) { if (error && fail_ci) {
throw error; throw error;
} else if (error) { } else if (error) {
@@ -2351,6 +2352,11 @@ try {
}); });
}; };
}); });
} catch (error) {
core.setFailed(
`Codecov failed with the following error: ${error.message}`
);
}
}); });
} catch (error) { } catch (error) {
if (fail_ci) { if (fail_ci) {

View File

@@ -32,6 +32,7 @@ try {
url: "https://codecov.io/bash", url: "https://codecov.io/bash",
json: false json: false
}, (error, response, body) => { }, (error, response, body) => {
try {
if (error && fail_ci) { if (error && fail_ci) {
throw error; throw error;
} else if (error) { } else if (error) {
@@ -147,6 +148,11 @@ try {
}); });
}; };
}); });
} catch (error) {
core.setFailed(
`Codecov failed with the following error: ${error.message}`
);
}
}); });
} catch (error) { } catch (error) {
if (fail_ci) { if (fail_ci) {

2
package-lock.json generated
View File

@@ -1,6 +1,6 @@
{ {
"name": "codecov-action", "name": "codecov-action",
"version": "1.0.11", "version": "1.0.12",
"lockfileVersion": 1, "lockfileVersion": 1,
"requires": true, "requires": true,
"dependencies": { "dependencies": {

View File

@@ -1,6 +1,6 @@
{ {
"name": "codecov-action", "name": "codecov-action",
"version": "1.0.11", "version": "1.0.12",
"description": "Upload coverage reports to Codecov from GitHub Actions", "description": "Upload coverage reports to Codecov from GitHub Actions",
"main": "index.js", "main": "index.js",
"scripts": { "scripts": {