Replace RequestError with the HTTP-style error classes

clusterio#999 removed RequestError. Handlers now throw NotFoundError,
ValidationError, ConflictError or UnavailableError, and exp_auto_restart
treats any ClientError from the host as a final refusal.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
bbassieandClaude Opus 5.5 committed 2026-10-28 23:43:25 +00:00
1 parent afc1d35668
commit 389004d652
8 files changed
+32 -32

No files matched your search

+11 -11
View File
@@ -233,7 +233,7 @@ export class ControllerPlugin {
async handleGroupCreateRequest(request: messages.GroupCreateRequest) {
if ([...this.groups.values()].some(g => g.name === request.name)) {
throw new lib.RequestError(`Group with name '${request.name}' already exists`);
throw new lib.ConflictError(`Group with name '${request.name}' already exists`);
}
let id = Math.random() * 2**31 | 0;
@@ -249,7 +249,7 @@ export class ControllerPlugin {
async handleGroupUpdateRequest(request: messages.GroupUpdateRequest) {
const group = request.group;
if (group.id === undefined || !this.groups.has(group.id)) {
throw new lib.RequestError(`Group with ID ${group.id} does not exist`);
throw new lib.NotFoundError(`Group with ID ${group.id} does not exist`);
}
this.groups.set(group);
@@ -260,7 +260,7 @@ export class ControllerPlugin {
const group = this.groups.getMutable(groupId);
if (!group) {
throw new lib.RequestError(`Group with ID ${groupId} does not exist`);
throw new lib.NotFoundError(`Group with ID ${groupId} does not exist`);
}
this.groups.delete(group);
@@ -269,7 +269,7 @@ export class ControllerPlugin {
async handleGroupGetRequest(request: messages.GroupGetRequest) {
const group = this.groups.get(request.groupId);
if (!group) {
throw new lib.RequestError(`Group with ID ${request.groupId} does not exist`);
throw new lib.NotFoundError(`Group with ID ${request.groupId} does not exist`);
}
return group;
@@ -286,7 +286,7 @@ export class ControllerPlugin {
async handleAssignmentCreateRequest(request: messages.AssignmentCreateRequest) {
const { name, groupId } = request;
if (this.manualAssignments.has(name)) {
throw new lib.RequestError(`Assignment for '${name}' already exists`);
throw new lib.ConflictError(`Assignment for '${name}' already exists`);
}
const assignment = new messages.AssignmentRecord(name, groupId);
@@ -297,7 +297,7 @@ export class ControllerPlugin {
async handleAssignmentUpdateRequest(request: messages.AssignmentUpdateRequest) {
const assignment = request.assignment;
if (!this.manualAssignments.has(assignment.name)) {
throw new lib.RequestError(`Assignment for '${assignment.name}' does not exist`);
throw new lib.NotFoundError(`Assignment for '${assignment.name}' does not exist`);
}
this.manualAssignments.set(assignment);
@@ -308,7 +308,7 @@ export class ControllerPlugin {
const assignment = this.manualAssignments.getMutable(name);
if (!assignment) {
throw new lib.RequestError(`Assignment for '${name}' does not exist`);
throw new lib.NotFoundError(`Assignment for '${name}' does not exist`);
}
this.manualAssignments.delete(assignment);
@@ -327,7 +327,7 @@ export class ControllerPlugin {
const assignment = this.manualAssignments.get(request.name);
if (!assignment) {
throw new lib.RequestError(`Assignment for '${request.name}' does not exist`);
throw new lib.NotFoundError(`Assignment for '${request.name}' does not exist`);
}
return assignment;
@@ -364,7 +364,7 @@ export class ControllerPlugin {
async handleRoleMappingUpdateRequest(request: messages.RoleMappingUpdateRequest) {
const roleMapping = request.roleMapping;
if (roleMapping.id === undefined || !this.roleMappings.has(roleMapping.id)) {
throw new lib.RequestError(`Role mapping with ID ${roleMapping.id} does not exist`);
throw new lib.NotFoundError(`Role mapping with ID ${roleMapping.id} does not exist`);
}
const existing = new Set(
@@ -386,7 +386,7 @@ export class ControllerPlugin {
const mapping = this.roleMappings.getMutable(id);
if (!mapping) {
throw new lib.RequestError(`Role mapping with ID ${id} does not exist`);
throw new lib.NotFoundError(`Role mapping with ID ${id} does not exist`);
}
this.roleMappings.delete(mapping);
@@ -395,7 +395,7 @@ export class ControllerPlugin {
async handleRoleMappingGetRequest(request: messages.RoleMappingGetRequest) {
const mapping = this.roleMappings.get(request.id);
if (!mapping) {
throw new lib.RequestError(`Role mapping with ID ${request.id} does not exist`);
throw new lib.NotFoundError(`Role mapping with ID ${request.id} does not exist`);
}
return mapping;