lib/interfaces/express.js
function makeExpressHandler(client, config) {
  /**
   * The Express Error Handler function is an interface for the error handler
   * stack into the Express architecture.
   * @function expressErrorHandler
   * @param {Any} err - a error of some type propagated by the express plugin
   *  stack
   * @param {Object} req - an Express request object
   * @param {Object} res - an Express response object
   * @param {Function} next - an Express continuation callback
   * @returns {ErrorMessage} - Returns the ErrorMessage instance
   */
  function expressErrorHandler(err, req, res, next) {
    var ctxService = '';
    var ctxVersion = '';
    
    if (isObject(config)) {
      ctxService = config.getServiceContext().service;
      ctxVersion = config.getServiceContext().version;
    }

    var em = new ErrorMessage()
                 .consumeRequestInformation(
                     expressRequestInformationExtractor(req, res))
                 .setServiceContext(ctxService, ctxVersion);

    errorHandlerRouter(err, em);

    if (isObject(client) && isFunction(client.sendError)) {
      client.sendError(em);
    }

    if (isFunction(next)) {
      next(err);
    }

    return em;
  }

  return expressErrorHandler;
}
function makeExpressHandler(client, config) {
  /**
   * The Express Error Handler function is an interface for the error handler
   * stack into the Express architecture.
   * @function expressErrorHandler
   * @param {Any} err - a error of some type propagated by the express plugin
   *  stack
   * @param {Object} req - an Express request object
   * @param {Object} res - an Express response object
   * @param {Function} next - an Express continuation callback
   * @returns {ErrorMessage} - Returns the ErrorMessage instance
   */
  function expressErrorHandler(err, req, res, next) {
    var ctxService = '';
    var ctxVersion = '';
    
    if (isObject(config)) {
      ctxService = config.getServiceContext().service;
      ctxVersion = config.getServiceContext().version;
    }

    var em = new ErrorMessage()
                 .consumeRequestInformation(
                     expressRequestInformationExtractor(req, res))
                 .setServiceContext(ctxService, ctxVersion);

    errorHandlerRouter(err, em);

    if (isObject(client) && isFunction(client.sendError)) {
      client.sendError(em);
    }

    if (isFunction(next)) {
      next(err);
    }

    return em;
  }

  return expressErrorHandler;
}
function makeExpressHandler ( client , config ) { /**
   * The Express Error Handler function is an interface for the error handler
   * stack into the Express architecture.
   * @function expressErrorHandler
   * @param {Any} err - a error of some type propagated by the express plugin
   *  stack
   * @param {Object} req - an Express request object
   * @param {Object} res - an Express response object
   * @param {Function} next - an Express continuation callback
   * @returns {ErrorMessage} - Returns the ErrorMessage instance
   */ function expressErrorHandler ( err , req , res , next ) { var ctxService = '' ; var ctxVersion = '' ; if ( isObject ( config ) ) { ctxService = config . getServiceContext ( ) . service ; ctxVersion = config . getServiceContext ( ) . version ; } var em = new ErrorMessage ( ) . consumeRequestInformation ( expressRequestInformationExtractor ( req , res ) ) . setServiceContext ( ctxService , ctxVersion ) ; errorHandlerRouter ( err , em ) ; if ( isObject ( client ) && isFunction ( client . sendError ) ) { client . sendError ( em ) ; } if ( isFunction ( next ) ) { next ( err ) ; } return em ; } return expressErrorHandler ; }
Returns a function that can be used as an express error handling middleware.
@function makeExpressHandler
@param {AuthClient} client - an inited Auth Client instance
@param {NormalizedConfigurationVariables} config  - the environmental
configuration
@returns {expressErrorHandler} - a function that can be used as an express
error handling middleware.
Returns a function that can be used as an express error handling middleware .