function _withEnumerableProperties()

in src/Errors/index.ts [83:101]


function _withEnumerableProperties(error: any) {
  if (error instanceof Error) {
    const extendedError: ExtendedError = <ExtendedError>(<any>error);
    const ret: any = Object.assign(
      {
        errorType: extendedError.name,
        errorMessage: extendedError.message,
        code: extendedError.code,
      },
      extendedError
    );
    if (typeof extendedError.stack == "string") {
      ret.stack = extendedError.stack.split("\n");
    }
    return ret;
  } else {
    return error;
  }
}