Custom Errors #

Pragma Engine supports creating and throwing custom errors from both plugins and custom services. This is generally the best way to stop a call and return the error to the client.

Creation and Usage #

To create a new custom error, add a new ExtError option in the 5-ext/ext-protos/src/main/proto/extensions/errorsExt.proto file.

enum ExtError {
   option (unreal_enum_name) = "ExtError";

   UNKNOWN_EXT_ERROR = 0;

   MY_CUSTOM_ERROR = 1;
}
Remember to run make ext-protos to register these changes before attempting to reference the new custom error.

To trigger the custom error, throw an ExtException with the new ExtError enum value as the error parameter.

throw ExtException(ExtError.MY_CUSTOM_ERROR, "something went wrong")

This is translated into a ServiceError returned to the client SDK. It can then be handled similarly to the standard provided PragmaErrors.