errors.ts

 1// SPDX-FileCopyrightText: Amolith <amolith@secluded.site>
 2//
 3// SPDX-License-Identifier: GPL-3.0-or-later
 4
 5export class RumiloError extends Error {
 6  readonly code: string;
 7
 8  constructor(message: string, code: string) {
 9    super(message);
10    this.name = this.constructor.name;
11    this.code = code;
12  }
13}
14
15export class ConfigError extends RumiloError {
16  constructor(message: string) {
17    super(message, "CONFIG_ERROR");
18  }
19}
20
21export class FetchError extends RumiloError {
22  constructor(url: string, reason: string) {
23    super(`Failed to fetch ${url}: ${reason}`, "FETCH_ERROR");
24  }
25}
26
27export class CloneError extends RumiloError {
28  constructor(uri: string, reason: string) {
29    super(`Failed to clone ${uri}: ${reason}`, "CLONE_ERROR");
30  }
31}
32
33export class WorkspaceError extends RumiloError {
34  constructor(message: string) {
35    super(message, "WORKSPACE_ERROR");
36  }
37}
38
39export class ToolInputError extends RumiloError {
40  constructor(message: string) {
41    super(message, "TOOL_INPUT_ERROR");
42  }
43}
44
45export class AgentError extends RumiloError {
46  constructor(message: string) {
47    super(message, "AGENT_ERROR");
48  }
49}