https://github.com/mikeludemann/error-classes
Some different classes for handling the error types and more
https://github.com/mikeludemann/error-classes
classes custom-error custom-error-class error error-classes error-handling
Last synced: 8 months ago
JSON representation
Some different classes for handling the error types and more
- Host: GitHub
- URL: https://github.com/mikeludemann/error-classes
- Owner: mikeludemann
- License: mit
- Created: 2020-04-06T12:49:40.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2020-04-07T15:04:21.000Z (almost 6 years ago)
- Last Synced: 2025-03-28T02:49:01.308Z (about 1 year ago)
- Topics: classes, custom-error, custom-error-class, error, error-classes, error-handling
- Language: JavaScript
- Size: 2.93 KB
- Stars: 1
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# error-classes
Some different classes for handling the error types and more
## Examples
```js
import { StringError, NumberError, ArrayError, ObjectError, SymbolError, NullError, BooleanError, DateError, FunctionError, ValidationError, DatabaseError, PermissionError, InternalError, ResourceNotFoundError } from 'error-classes';
...
var elem = ...;
try {
foobar();
} catch(err) {
throw new StringError(err, elem);
} finally {
console.log("...");
}
try {
foobar();
} catch(err) {
throw new NumberError(err, elem);
} finally {
console.log("...");
}
try {
foobar();
} catch(err) {
throw new ArrayError(err, elem);
} finally {
console.log("...");
}
try {
foobar();
} catch(err) {
throw new ObjectError(err, elem);
} finally {
console.log("...");
}
try {
foobar();
} catch(err) {
throw new SymbolError(err, elem);
} finally {
console.log("...");
}
try {
foobar();
} catch(err) {
throw new NullError(err, elem);
} finally {
console.log("...");
}
try {
foobar();
} catch(err) {
throw new BooleanError(err, elem);
} finally {
console.log("...");
}
try {
foobar();
} catch(err) {
throw new DateError(err, elem);
} finally {
console.log("...");
}
try {
foobar();
} catch(err) {
throw new FunctionError(err, elem);
} finally {
console.log("...");
}
try {
foobar();
} catch(err) {
throw new ValidationError(err, elem);
} finally {
console.log("...");
}
try {
foobar();
} catch(err) {
throw new DatabaseError(err, elem);
} finally {
console.log("...");
}
try {
foobar();
} catch(err) {
throw new PermissionError(err, elem);
} finally {
console.log("...");
}
try {
foobar();
} catch(err) {
throw new ResourceNotFoundError("test", elem);
} finally {
console.log("...");
}
try {
foobar();
} catch(err) {
throw new InternalError(err);
} finally {
console.log("...");
}
...
```