Files
factorio-clusterio/docs/devs/plugin-migration-to-2.1.md
T
bbassieandClaude Opus 5.5 54e9340e61 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>
2026-10-27 22:03:13 +00:00

1.3 KiB

Migrating Plugins to 2.1

This guide covers the changes needed to bring a plugin written for 2.0 up to 2.1. Plugins still on an alpha should start with the 2.0 guide.

Request errors

RequestError is gone. Errors thrown by request handlers are now received by the requester as the same class, see Request errors. Replace RequestError with the class that fits:

  • Invalid input: ValidationError.
  • Operation disabled by config: ForbiddenError.
  • Missing instance, user, save etc.: NotFoundError.
  • Instance running, name taken etc.: ConflictError.
  • Host not connected, instance not running: UnavailableError.
  • Timeouts: TimeoutError.

catch blocks that check err instanceof RequestError should check ClientError instead, or the specific class. Checks of err.code for remote errors can use instanceof, e.g. err instanceof lib.SessionLost.

The config errors lib.InvalidValue, lib.InvalidField and lib.InvalidAccess were renamed to lib.InvalidValueError, lib.InvalidFieldError and lib.InvalidAccessError.

Errors of classes that are not registered, like a TypeError from a bug, are received as InternalServerError. Plugins that define their own error classes need to list them in errors of the plugin declaration.