refactor(features): split entities into models/ + errors/ subdirs
All 5 features (auth, blog, marketing-pages, navigation; media has no entities yet) now follow Lazar's pattern: - entities/<x>.ts → entities/models/<x>.ts - entities/errors.ts → entities/errors/<domain>.ts + errors/common.ts Updates all import paths across factories, contracts, tests, use cases, controllers, repositories, integrations, and src/index.ts exports. navigation divergence: had no errors.ts; errors/header.ts + errors/common.ts added as new forward-looking stubs. Refactor log: docs/superpowers/refactor-logs/2026-05-05-lazar-pattern-conformance.md Spec: §5, §9.3 Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
17
packages/auth/src/entities/errors/auth.ts
Normal file
17
packages/auth/src/entities/errors/auth.ts
Normal file
@@ -0,0 +1,17 @@
|
||||
export class AuthenticationError extends Error {
|
||||
constructor(message: string, options?: ErrorOptions) {
|
||||
super(message, options);
|
||||
}
|
||||
}
|
||||
|
||||
export class UnauthenticatedError extends Error {
|
||||
constructor(message: string, options?: ErrorOptions) {
|
||||
super(message, options);
|
||||
}
|
||||
}
|
||||
|
||||
export class UnauthorizedError extends Error {
|
||||
constructor(message: string, options?: ErrorOptions) {
|
||||
super(message, options);
|
||||
}
|
||||
}
|
||||
5
packages/auth/src/entities/errors/common.ts
Normal file
5
packages/auth/src/entities/errors/common.ts
Normal file
@@ -0,0 +1,5 @@
|
||||
export class InputParseError extends Error {
|
||||
constructor(message: string, options?: ErrorOptions) {
|
||||
super(message, options);
|
||||
}
|
||||
}
|
||||
39
packages/auth/src/entities/errors/errors.test.ts
Normal file
39
packages/auth/src/entities/errors/errors.test.ts
Normal file
@@ -0,0 +1,39 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import {
|
||||
AuthenticationError,
|
||||
UnauthenticatedError,
|
||||
UnauthorizedError,
|
||||
} from "./auth";
|
||||
import { InputParseError } from "./common";
|
||||
|
||||
describe("AuthenticationError", () => {
|
||||
it("is an instance of Error with the given message", () => {
|
||||
const err = new AuthenticationError("bad credentials");
|
||||
expect(err).toBeInstanceOf(Error);
|
||||
expect(err.message).toBe("bad credentials");
|
||||
});
|
||||
});
|
||||
|
||||
describe("UnauthenticatedError", () => {
|
||||
it("is an instance of Error with the given message", () => {
|
||||
const err = new UnauthenticatedError("not logged in");
|
||||
expect(err).toBeInstanceOf(Error);
|
||||
expect(err.message).toBe("not logged in");
|
||||
});
|
||||
});
|
||||
|
||||
describe("UnauthorizedError", () => {
|
||||
it("is an instance of Error with the given message", () => {
|
||||
const err = new UnauthorizedError("forbidden");
|
||||
expect(err).toBeInstanceOf(Error);
|
||||
expect(err.message).toBe("forbidden");
|
||||
});
|
||||
});
|
||||
|
||||
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");
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user