Skip to content

Commit

Permalink
added sliglty better error handling again
Browse files Browse the repository at this point in the history
  • Loading branch information
jorgtho committed Sep 22, 2023
1 parent 49d403e commit 70f7c71
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions lib/e18.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
Expand All @@ -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
}
}
Expand All @@ -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
}
Expand Down

0 comments on commit 70f7c71

Please sign in to comment.