Skip to content

Commit

Permalink
error handling for getNextTestInfo (upon 500 axios error), #219
Browse files Browse the repository at this point in the history
  • Loading branch information
zepumph committed Oct 30, 2024
1 parent 155f552 commit c2d270f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
6 changes: 3 additions & 3 deletions js/node-client/getNextTestInfo.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,17 @@ module.exports = async function( options ) {

}, options );

let response = {};
let response = null;
try {
response = await axios( `${options.serverURL}/aquaserver/next-test?old=${options.old}` );
}
catch( e ) {
throw new Error( `axios failure code ${e.response.status} getting next-test: ${e.message}` );
}

if ( response.status !== 200 ) {
if ( response?.status !== 200 ) {
throw new Error( `nextTest request failed with status ${response.status} ${response}` );
}

return response.data || {};
return response?.data || null;
};
8 changes: 5 additions & 3 deletions js/node-client/runNextTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,11 @@ module.exports = async function( options ) {
testInfo = await getNextTestInfo( options );
winston.info( 'testInfo', JSON.stringify( testInfo ) );
}
await runTest( testInfo, options );
winston.debug( 'runTest completed' );
return;
if ( testInfo ) {
await runTest( testInfo, options );
winston.debug( 'runTest completed' );
return;
}
}
catch( e ) {
lastFailure = e;
Expand Down

0 comments on commit c2d270f

Please sign in to comment.