Constructor
# new NotFoundError(msg) → {NotFoundError}
Represents a failure in finding a model, resulting in a 404 HTTP status code
Error thrown when a requested resource is not found
Parameters:
Name | Type | Description |
---|---|---|
msg |
string
|
Error
|
The error message or Error object |
A new NotFoundError instance
Example
// Throw a not found error when a record doesn't exist
const user = await repository.findById(id);
if (!user) {
throw new NotFoundError(`User with ID ${id} not found`);
}