code: function buildErrorResponse(params) {
    params = params || {};
    params.error = params.error || {};
    var ERROR_CODES = models.CONSTANTS.ERROR_CODES;
  
    if (params.error.userDetail) {
      return params.error;
    }
  
    if (params.error) {
      var message = params.error.message || "";
      //If the message is about validation, the return a validation http response
      if (message.indexOf("validation") > -1) {
        params.code = params.code || ERROR_CODES.FH_FORMS_INVALID_PARAMETERS;
      }
    }
  
    //Mongoose Validation Failed
    if (params.error && params.error.errors) {
      var fieldKey = _.keys(params.error.errors)[0];
      params.userDetail = params.userDetail || params.error.errors[fieldKey].message;
      params.code = params.code || ERROR_CODES.FH_FORMS_INVALID_PARAMETERS;
    }
  
    var userDetail = params.userDetail || params.error.userDetail || params.error.message || "An Unexpected Error Occurred";
    var systemDetail = params.systemDetail || params.error.systemDetail || params.error.stack || "";
    var code = params.code || ERROR_CODES.FH_FORMS_UNEXPECTED_ERROR;
  
    return {
      userDetail: userDetail,
      systemDetail: systemDetail,
      code: code
    };
  }
docs: Common Error Response builder. 
  Thee should be a common error response from all feedhenry components.
  
  @param params - object containing error structures.