mirror of
https://github.com/fjogeleit/http-request-action.git
synced 2024-12-23 12:46:14 +00:00
Improve Request Error Handling
This commit is contained in:
parent
5d7e3ef283
commit
d3ea5fce44
2 changed files with 22 additions and 2 deletions
10
dist/index.js
vendored
10
dist/index.js
vendored
|
@ -2653,7 +2653,17 @@ const instance = axios.create(instanceConfig);
|
||||||
|
|
||||||
core.setOutput('response', JSON.stringify(response.data))
|
core.setOutput('response', JSON.stringify(response.data))
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
if (error.toJSON) {
|
||||||
|
core.setOutput(error.toJSON());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (error.response) {
|
||||||
core.setFailed(JSON.stringify({ code: error.response.code, message: error.response.data }))
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
})()
|
})()
|
||||||
|
|
||||||
|
|
10
src/index.js
10
src/index.js
|
@ -57,6 +57,16 @@ const instance = axios.create(instanceConfig);
|
||||||
|
|
||||||
core.setOutput('response', JSON.stringify(response.data))
|
core.setOutput('response', JSON.stringify(response.data))
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
if (error.toJSON) {
|
||||||
|
core.setOutput(error.toJSON());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (error.response) {
|
||||||
core.setFailed(JSON.stringify({ code: error.response.code, message: error.response.data }))
|
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