src/handlers.js
function onClientPostRequestHandler (ctx, err) {
  // extension error
  if (err) {
    let error = null;
    if (err instanceof SuperError) {
      error = err.rootCause || err.cause || err;
    } else {
      error = err;
    }
    const internalError = new Errors.MostlyError(Constants.EXTENSION_ERROR, ctx.errorDetails).causedBy(err);
    ctx.log.error(internalError);

    ctx.emit('clientResponseError', error);

    ctx._execute(error);
    return;
  }

  if (ctx._response.payload.error) {
    debug('act:response.payload.error', ctx._response.payload.error);
    let error = Errio.fromObject(ctx._response.payload.error);

    const internalError = new Errors.BusinessError(Constants.BUSINESS_ERROR, ctx.errorDetails).causedBy(error);
    ctx.log.error(internalError);

    ctx.emit('clientResponseError', error);

    ctx._execute(error);
    return;
  }

  ctx._execute(null, ctx._response.payload.result);
}
function onClientPostRequestHandler (ctx, err) {
  // extension error
  if (err) {
    let error = null;
    if (err instanceof SuperError) {
      error = err.rootCause || err.cause || err;
    } else {
      error = err;
    }
    const internalError = new Errors.MostlyError(Constants.EXTENSION_ERROR, ctx.errorDetails).causedBy(err);
    ctx.log.error(internalError);

    ctx.emit('clientResponseError', error);

    ctx._execute(error);
    return;
  }

  if (ctx._response.payload.error) {
    debug('act:response.payload.error', ctx._response.payload.error);
    let error = Errio.fromObject(ctx._response.payload.error);

    const internalError = new Errors.BusinessError(Constants.BUSINESS_ERROR, ctx.errorDetails).causedBy(error);
    ctx.log.error(internalError);

    ctx.emit('clientResponseError', error);

    ctx._execute(error);
    return;
  }

  ctx._execute(null, ctx._response.payload.result);
}
function onClientPostRequestHandler ( ctx , err ) { // extension error if ( err ) { let error = null ; if ( err instanceof SuperError ) { error = err . rootCause || err . cause || err ; } else { error = err ; } const internalError = new Errors . MostlyError ( Constants . EXTENSION_ERROR , ctx . errorDetails ) . causedBy ( err ) ; ctx . log . error ( internalError ) ; ctx . emit ( 'clientResponseError' , error ) ; ctx . _execute ( error ) ; return ; } if ( ctx . _response . payload . error ) { debug ( 'act:response.payload.error' , ctx . _response . payload . error ) ; let error = Errio . fromObject ( ctx . _response . payload . error ) ; const internalError = new Errors . BusinessError ( Constants . BUSINESS_ERROR , ctx . errorDetails ) . causedBy ( error ) ; ctx . log . error ( internalError ) ; ctx . emit ( 'clientResponseError' , error ) ; ctx . _execute ( error ) ; return ; } ctx . _execute ( null , ctx . _response . payload . result ) ; }
Is called after the client has received and decoded the request
Is called after the client has received and decoded the request