Initial commit
This commit is contained in:
6
packages/marketing-pages/src/entities/errors/common.ts
Normal file
6
packages/marketing-pages/src/entities/errors/common.ts
Normal file
@@ -0,0 +1,6 @@
|
||||
export class InputParseError extends Error {
|
||||
constructor(message: string, options?: ErrorOptions) {
|
||||
super(message, options);
|
||||
this.name = "InputParseError";
|
||||
}
|
||||
}
|
||||
24
packages/marketing-pages/src/entities/errors/errors.test.ts
Normal file
24
packages/marketing-pages/src/entities/errors/errors.test.ts
Normal file
@@ -0,0 +1,24 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { PageNotFoundError } from "./page";
|
||||
import { InputParseError } from "./common";
|
||||
|
||||
describe("PageNotFoundError", () => {
|
||||
it("uses the default message when none is given", () => {
|
||||
const err = new PageNotFoundError();
|
||||
expect(err).toBeInstanceOf(Error);
|
||||
expect(err.message).toBe("Page not found");
|
||||
});
|
||||
|
||||
it("uses a custom message when provided", () => {
|
||||
const err = new PageNotFoundError("could not find page /about");
|
||||
expect(err.message).toBe("could not find page /about");
|
||||
});
|
||||
});
|
||||
|
||||
describe("InputParseError", () => {
|
||||
it("is an instance of Error with the given message", () => {
|
||||
const err = new InputParseError("invalid input");
|
||||
expect(err).toBeInstanceOf(Error);
|
||||
expect(err.message).toBe("invalid input");
|
||||
});
|
||||
});
|
||||
6
packages/marketing-pages/src/entities/errors/page.ts
Normal file
6
packages/marketing-pages/src/entities/errors/page.ts
Normal file
@@ -0,0 +1,6 @@
|
||||
export class PageNotFoundError extends Error {
|
||||
constructor(message = "Page not found", options?: ErrorOptions) {
|
||||
super(message, options);
|
||||
this.name = "PageNotFoundError";
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user