-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove status param from GroutError constructor
- Loading branch information
1 parent
507c75d
commit 9224ee0
Showing
7 changed files
with
25 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,14 @@ | ||
import { ErrorType } from "./errorType"; | ||
import { ErrorType, ErrorTypeStatuses } from "./errorType"; | ||
|
||
export class GroutError extends Error { | ||
status: number; | ||
errorType: ErrorType; | ||
|
||
constructor(message: string, status: number, errorType: ErrorType) { | ||
constructor(message: string, errorType: ErrorType) { | ||
super(message); | ||
|
||
this.name = "GroutError"; | ||
this.status = status; | ||
this.status = ErrorTypeStatuses[errorType]; | ||
this.errorType = errorType; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { describe, expect, test, vi, beforeEach } from "vitest"; | ||
import { GroutError } from "../../../src/errors/groutError"; | ||
import { ErrorType } from "../../../src/errors/errorType"; | ||
|
||
describe("GroutError", () => { | ||
test("is constructed with expected status value", () => { | ||
expect(new GroutError("test", ErrorType.BAD_REQUEST).status).toBe(400); | ||
expect(new GroutError("test", ErrorType.NOT_FOUND).status).toBe(404); | ||
expect(new GroutError("test", ErrorType.UNEXPECTED_ERROR).status).toBe( | ||
500 | ||
); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters