fix: standardize error classes in shared service modules
Replace raw `Error` with `UserError` for user-facing conditions (invalid trade state, user not found, permission/channel type checks) and `SystemError` for internal failures (DB insert failures, external API errors, missing config). Improves Discord UX by ensuring user-facing errors are surfaced cleanly via withCommandErrorHandling. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import { eq } from "drizzle-orm";
|
||||
import { gameSettings } from "@db/schema";
|
||||
import { DrizzleClient } from "@shared/db/DrizzleClient";
|
||||
import { SystemError } from "@shared/lib/errors";
|
||||
import type {
|
||||
LevelingConfig,
|
||||
EconomyConfig,
|
||||
@@ -88,7 +89,7 @@ export const gameSettingsService = {
|
||||
const existing = await gameSettingsService.getSettings(false);
|
||||
|
||||
if (!existing) {
|
||||
throw new Error("Game settings not found. Initialize settings first.");
|
||||
throw new SystemError("Game settings not found. Initialize settings first.");
|
||||
}
|
||||
|
||||
const updates: Partial<GameSettingsData> = { [section]: value };
|
||||
@@ -101,7 +102,7 @@ export const gameSettingsService = {
|
||||
const settings = await gameSettingsService.getSettings(false);
|
||||
|
||||
if (!settings) {
|
||||
throw new Error("Game settings not found. Initialize settings first.");
|
||||
throw new SystemError("Game settings not found. Initialize settings first.");
|
||||
}
|
||||
|
||||
const commands = {
|
||||
|
||||
Reference in New Issue
Block a user