ATlast — you'll never need to find your favorites on another platform again. Find your favs in the ATmosphere.
atproto
16
fork

Configure Feed

Select the types of activity you want to include in your feed.

refactor: move error classes to hono api

byarielm.fyi c305845e b1f71bbc

verified
+64
+11
packages/api/src/errors/ApiError.ts
··· 1 + export class ApiError extends Error { 2 + constructor( 3 + message: string, 4 + public statusCode: number = 500, 5 + public details?: string, 6 + ) { 7 + super(message); 8 + this.name = "ApiError"; 9 + Object.setPrototypeOf(this, ApiError.prototype); 10 + } 11 + }
+9
packages/api/src/errors/AuthenticationError.ts
··· 1 + import { ApiError } from "./ApiError"; 2 + 3 + export class AuthenticationError extends ApiError { 4 + constructor(message: string = "Authentication required", details?: string) { 5 + super(message, 401, details); 6 + this.name = "AuthenticationError"; 7 + Object.setPrototypeOf(this, AuthenticationError.prototype); 8 + } 9 + }
+9
packages/api/src/errors/DatabaseError.ts
··· 1 + import { ApiError } from "./ApiError"; 2 + 3 + export class DatabaseError extends ApiError { 4 + constructor(message: string = "Database operation failed", details?: string) { 5 + super(message, 500, details); 6 + this.name = "DatabaseError"; 7 + Object.setPrototypeOf(this, DatabaseError.prototype); 8 + } 9 + }
+9
packages/api/src/errors/NotFoundError.ts
··· 1 + import { ApiError } from "./ApiError"; 2 + 3 + export class NotFoundError extends ApiError { 4 + constructor(message: string = "Resource not found", details?: string) { 5 + super(message, 404, details); 6 + this.name = "NotFoundError"; 7 + Object.setPrototypeOf(this, NotFoundError.prototype); 8 + } 9 + }
+9
packages/api/src/errors/ValidationError.ts
··· 1 + import { ApiError } from "./ApiError"; 2 + 3 + export class ValidationError extends ApiError { 4 + constructor(message: string, details?: string) { 5 + super(message, 400, details); 6 + this.name = "ValidationError"; 7 + Object.setPrototypeOf(this, ValidationError.prototype); 8 + } 9 + }
+17
packages/api/src/errors/index.ts
··· 1 + export * from "./ApiError"; 2 + export * from "./AuthenticationError"; 3 + export * from "./ValidationError"; 4 + export * from "./NotFoundError"; 5 + export * from "./DatabaseError"; 6 + 7 + export const ERROR_MESSAGES = { 8 + NO_SESSION_COOKIE: "No session cookie", 9 + INVALID_SESSION: "Invalid or expired session", 10 + MISSING_PARAMETERS: "Missing required parameters", 11 + OAUTH_FAILED: "OAuth authentication failed", 12 + DATABASE_ERROR: "Database operation failed", 13 + PROFILE_FETCH_FAILED: "Failed to fetch profile", 14 + SEARCH_FAILED: "Search operation failed", 15 + FOLLOW_FAILED: "Follow operation failed", 16 + SAVE_FAILED: "Failed to save results", 17 + } as const;