nl_tokens: verify the current status to make sure it can be updated to the desired status
pl_tokens: function verifyStatusUpdate ( exId , desiredStatus ) { if ( ! desiredStatus || ! _isValidStatus ( desiredStatus ) ) { const error = new Error ( ` ${ desiredStatus } ` ) ; error . statusCode = 422 ; return Promise . reject ( error ) ; } return getStatus ( exId ) . then ( ( status ) => { // when setting the same status to shouldn't throw an error if ( desiredStatus === status ) { return Promise . resolve ( ) ; } // when the current status is running it cannot be set to an init status if ( _isRunningStatus ( status ) && _isInitStatus ( desiredStatus ) ) { const error = new <mask> ( ` ${ status } ${ desiredStatus } ` ) ; return Promise . reject ( error ) ; } // when the status is a terminal status, it cannot be set to again if ( _isTerminalStatus ( status ) ) { const error = new Error ( ` ${ status } ${ desiredStatus } ` ) ; return Promise . reject ( error ) ; } // otherwise allow the update return Promise . resolve ( status ) ; } ) ; }