function _withEnumerableProperties()

in src/Errors.js [83:100]


function _withEnumerableProperties(error) {
  if (error instanceof Error) {
    let ret = Object.assign(
      {
        errorType: error.name,
        errorMessage: error.message,
        code: error.code,
      },
      error,
    );
    if (typeof error.stack == 'string') {
      ret.stack = error.stack.split('\n');
    }
    return ret;
  } else {
    return error;
  }
}