Skip to content

Commit

Permalink
fix: unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
favoyang committed Oct 16, 2022
1 parent 5c2ca26 commit 9d6a52e
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,14 +65,15 @@ export const PACKAGE_JSON_FILE = 'package.json';
*
* @param error
*/
export function wrapError(err: unknown): VerdaccioError {
if (err instanceof Error) {
if ('code' in err) return err;
return getInternalError(err.message);
} else {
export function wrapError(err: unknown): VerdaccioError {
const obj = err as object;
if ('code' in obj && 'message' in obj)
return err;
else if ('message' in obj)
return getInternalError(obj.message as string);
else
return getInternalError(String(err));
}
}
}

/**
* Load verdaccio config file
Expand Down

0 comments on commit 9d6a52e

Please sign in to comment.