Skip to content

Commit

Permalink
Update CHANGELOG
Browse files Browse the repository at this point in the history
  • Loading branch information
ingalls committed Apr 29, 2024
1 parent fd7f42a commit 6f50902
Show file tree
Hide file tree
Showing 7 changed files with 292 additions and 253 deletions.
6 changes: 0 additions & 6 deletions .eslintrc.json

This file was deleted.

4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@

## Version History

### v2.4.0

- :arrow_up: Update typescript and fix related build issues around status code parsing

### v2.3.3

- :bug: Further extends fixes
Expand Down
12 changes: 12 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import eslint from '@eslint/js';
import tseslint from 'typescript-eslint';

export default tseslint.config(
eslint.configs.recommended,
...tseslint.configs.recommended,
{
"rules": {
"@typescript-eslint/no-explicit-any": "warn"
}
}
);
10 changes: 7 additions & 3 deletions index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,13 @@ export default class PublicError extends Error {
if (typeof err === 'object') {
const serr = err as StatusError;

if ((Object.hasOwn(serr, 'status') ? serr.status : 500) === 500) console.error(err);
res.status(Object.hasOwn(serr, 'status') ? serr.status : 500).send({
status: Object.hasOwn(serr, 'status') ? serr.status : 500,
const status = Object.hasOwn(serr, 'status') ? (!isNaN(Number(serr.status)) ? Number(serr.status) : 500 ) : 500;
if (status === 500) {
console.error(err);
}

res.status(status).send({
status: status,
message: Object.hasOwn(serr, 'safe') ? serr.safe : 'Internal Server Error',
messages
});
Expand Down
Loading

0 comments on commit 6f50902

Please sign in to comment.