diff --git a/dist/index.js b/dist/index.js index 2a05b01..df51b0e 100644 --- a/dist/index.js +++ b/dist/index.js @@ -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); + } } })() diff --git a/src/index.js b/src/index.js index 2200c9c..38c535d 100644 --- a/src/index.js +++ b/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); + } } })()