Skip to content

Commit 60c5e82

Browse files
author
roman.vasilev
committed
chore: Added expect lib, updated readme
1 parent 322789f commit 60c5e82

File tree

3 files changed

+14113
-0
lines changed

3 files changed

+14113
-0
lines changed

README.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,34 @@
11
# errorlings
2+
Common errors for your application.
3+
4+
## API
5+
Create error (all parameters optional and can be passed in any order)
6+
```ts
7+
const e = new CustomEror(status: number, message: string, code: string, inner: Error, { data: any });
8+
```
9+
Rules of detecting type of parameter:
10+
* typeof number: status
11+
* first string: message
12+
* second string: code
13+
* instanceof Error: inner
14+
* object with key data: data
15+
16+
Using options object as parameter:
17+
```ts
18+
const err = new CustomEror({
19+
status?: number;
20+
data?: any;
21+
code?: string;
22+
inner?: Error;
23+
message?: string;
24+
});
25+
```
26+
27+
### Error classes and defaults
28+
* `ExceptionError`
29+
* `ForbiddenError` (status: 403, message: You don't have permission to do that.)
30+
* `NotFoundError` (status: 404)
31+
* `ValidationError` (status: 400)
232

333
## Changelog
434
See [CHANGELOG.md](CHANGELOG.md)

0 commit comments

Comments
 (0)