diff --git a/lib/e18.js b/lib/e18.js index 26f6977..6788fa0 100644 --- a/lib/e18.js +++ b/lib/e18.js @@ -21,8 +21,10 @@ module.exports.createJob = async blobName => { const { data } = await axios.post(`${E18_URL}/jobs`, payload, headers) return data._id } catch (error) { - const { status, message } = error.response - logger('error', ['e18', 'createJob', message, status]) + const errorMsg = error.response?.data || error.stack || error.toString() + const status = error.response?.status || 500 + const message = error.response?.message || error.toString() + logger('error', ['e18', 'createJob', message, status, errorMsg]) throw error } } @@ -38,8 +40,10 @@ module.exports.createTask = async (jobId, payload) => { const { data } = await axios.post(`${E18_URL}/jobs/${jobId}/tasks`, payload, headers) return data._id } catch (error) { - const { status, message } = error.response - logger('error', ['e18', 'createTask', message, status]) + const errorMsg = error.response?.data || error.stack || error.toString() + const status = error.response?.status || 500 + const message = error.response?.message || error.toString() + logger('error', ['e18', 'createTask', message, status, errorMsg]) throw error } } @@ -56,8 +60,10 @@ module.exports.complete = async blobContent => { blobContent.flow.e18Job = { status: 'finished' } return blobContent } catch (error) { - const { status, message } = error.response - logger('error', ['e18', 'complete', message, status]) + const errorMsg = error.response?.data || error.stack || error.toString() + const status = error.response?.status || 500 + const message = error.response?.message || error.toString() + logger('error', ['e18', 'complete', message, status, errorMsg]) blobContent.flow.e18Job = { status: 'failed' } return blobContent }