mirror of
https://github.com/fjogeleit/http-request-action.git
synced 2024-12-27 20:34:43 -05:00
Improve Request Error Handling
This commit is contained in:
parent
5d7e3ef283
commit
d3ea5fce44
2 changed files with 22 additions and 2 deletions
12
dist/index.js
vendored
12
dist/index.js
vendored
|
@ -2653,7 +2653,17 @@ const instance = axios.create(instanceConfig);
|
|||
|
||||
core.setOutput('response', JSON.stringify(response.data))
|
||||
} catch (error) {
|
||||
core.setFailed(JSON.stringify({ code: error.response.code, message: error.response.data }))
|
||||
if (error.toJSON) {
|
||||
core.setOutput(error.toJSON());
|
||||
}
|
||||
|
||||
if (error.response) {
|
||||
core.setFailed(JSON.stringify({ code: error.response.code, message: error.response.data }))
|
||||
} else if (error.request) {
|
||||
core.setFailed(JSON.stringify({ error: "no response received" }));
|
||||
} else {
|
||||
core.setFailed(error.message);
|
||||
}
|
||||
}
|
||||
})()
|
||||
|
||||
|
|
12
src/index.js
12
src/index.js
|
@ -57,6 +57,16 @@ const instance = axios.create(instanceConfig);
|
|||
|
||||
core.setOutput('response', JSON.stringify(response.data))
|
||||
} catch (error) {
|
||||
core.setFailed(JSON.stringify({ code: error.response.code, message: error.response.data }))
|
||||
if (error.toJSON) {
|
||||
core.setOutput(error.toJSON());
|
||||
}
|
||||
|
||||
if (error.response) {
|
||||
core.setFailed(JSON.stringify({ code: error.response.code, message: error.response.data }))
|
||||
} else if (error.request) {
|
||||
core.setFailed(JSON.stringify({ error: "no response received" }));
|
||||
} else {
|
||||
core.setFailed(error.message);
|
||||
}
|
||||
}
|
||||
})()
|
||||
|
|
Loading…
Reference in a new issue