mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-17 07:30:41 +09:00
Add UnavailableError and keep the PermissionError name
Host not connected, host shutting down and instance not running are now UnavailableError (503) instead of ConflictError. The request error migration notes move to a new 2.1 guide, since this ships in 2.1. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
1c7c00b033
commit
54e9340e61
23 files changed
+78
-66
No files matched your search
@@ -431,12 +431,12 @@ export default class ControlConnection extends BaseConnection {
|
||||
// Check connectivity
|
||||
let sourceHostConnection = this._controller.wsServer.hostConnections.get(sourceHostId);
|
||||
if (!sourceHostConnection || sourceHostConnection.connector.closing) {
|
||||
throw new lib.ConflictError("Source host is not connected to the controller");
|
||||
throw new lib.UnavailableError("Source host is not connected to the controller");
|
||||
}
|
||||
|
||||
let targetHostConnection = this._controller.wsServer.hostConnections.get(targetHostId);
|
||||
if (!targetHostConnection || targetHostConnection.connector.closing) {
|
||||
throw new lib.ConflictError("Target host is not connected to the controller");
|
||||
throw new lib.UnavailableError("Target host is not connected to the controller");
|
||||
}
|
||||
|
||||
// Create stream to proxy from target to source
|
||||
@@ -997,7 +997,7 @@ export default class ControlConnection extends BaseConnection {
|
||||
async handleNoteSetRequest(request: lib.NoteSetRequest) {
|
||||
const { resourceType, resourceId, content } = request;
|
||||
if (!resourceType || !resourceId) {
|
||||
throw new lib.RequestError("resourceType and resourceId must not be empty");
|
||||
throw new lib.ValidationError("resourceType and resourceId must not be empty");
|
||||
}
|
||||
this._controller.setNote(resourceType, resourceId, content, this.user.name);
|
||||
}
|
||||
|
||||
@@ -1476,13 +1476,13 @@ export default class Controller {
|
||||
}
|
||||
connection = this.wsServer.hostConnections.get(hostId);
|
||||
if (!connection) {
|
||||
throw new lib.ConflictError("Host containing instance is not connected");
|
||||
throw new lib.UnavailableError("Host containing instance is not connected");
|
||||
}
|
||||
|
||||
} else if (dst.type === lib.Address.host) {
|
||||
connection = this.wsServer.hostConnections.get(dst.id);
|
||||
if (!connection) {
|
||||
throw new lib.ConflictError("Host is not connected");
|
||||
throw new lib.UnavailableError("Host is not connected");
|
||||
}
|
||||
|
||||
} else {
|
||||
@@ -1570,7 +1570,7 @@ export default class Controller {
|
||||
}
|
||||
let connection = this.wsServer.hostConnections.get(hostId);
|
||||
if (!connection) {
|
||||
throw new lib.ConflictError("Host containing instance is not connected");
|
||||
throw new lib.UnavailableError("Host containing instance is not connected");
|
||||
}
|
||||
return await connection.send(request);
|
||||
}
|
||||
|
||||
@@ -74,7 +74,7 @@ export default class ControllerRouter {
|
||||
return false;
|
||||
}
|
||||
origin.connector.sendResponseError(
|
||||
new lib.ResponseError(msg || "Unroutable destination", "ConflictError"), message.src
|
||||
new lib.ResponseError(msg || "Unroutable destination", "UnavailableError"), message.src
|
||||
);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -173,7 +173,7 @@ export default class InstanceManager {
|
||||
* the instance will be unassigned.
|
||||
*
|
||||
* @throws {module:lib.NotFoundError} if the instance does not exist.
|
||||
* @throws {module:lib.ConflictError} if the target host is not connected.
|
||||
* @throws {module:lib.UnavailableError} if the target host is not connected.
|
||||
*/
|
||||
async assignInstance(
|
||||
instanceId: number,
|
||||
@@ -191,7 +191,7 @@ export default class InstanceManager {
|
||||
if (hostId !== null) {
|
||||
newHostConnection = hostConnections.get(hostId);
|
||||
if (!newHostConnection) {
|
||||
throw new lib.ConflictError("Target host is not connected to the controller");
|
||||
throw new lib.UnavailableError("Target host is not connected to the controller");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
|
||||
import {
|
||||
IUser, Role, SubscribableDatastore,
|
||||
PermissionDeniedError, PermissionName, permissions,
|
||||
PermissionError, PermissionName, permissions,
|
||||
} from "@clusterio/lib";
|
||||
|
||||
import UserRecord from "./UserRecord.js";
|
||||
@@ -141,6 +141,6 @@ export default class User extends UserRecord implements IUser {
|
||||
}
|
||||
}
|
||||
|
||||
throw new PermissionDeniedError("Permission denied");
|
||||
throw new PermissionError("Permission denied");
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user