Commit efa73fde authored by Yoann HOUPERT's avatar Yoann HOUPERT

manage error response

parent 336d380c
Pipeline #10054 passed with stage
in 2 minutes and 41 seconds
......@@ -60,7 +60,7 @@ const routesFactory = config => {
// Default Offline
const transcription = json.transcript;
// TODO use this when enhancement whill be integrate
// const transcription = JSON.parse(json.transcript)
// const transcription = JSON.parse(json.transcript).transcript
const jsonResponse = {
status: 0,
......@@ -74,8 +74,10 @@ const routesFactory = config => {
});
} else {
stt.transcript(body, (err, response, body) => {
if (err || response === undefined || body === undefined || response.statusCode !== successCode) {
if (err) {
return res.status(interalServerCode).json({module: 'Online transcription', error: 'Error during audio transcription', info: err.toString()});
} else if (response === undefined || body === undefined || response.statusCode !== successCode) {
return res.status(interalServerCode).json({module: 'Online transcription', error: 'Error during audio transcription'});
} else if (body.indexOf('No workers available') !== -1) {
return res.status(interalServerCode).json({module: 'Online transcription', error: 'No worker available for the moment.'});
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment