Skip to content

Common Error Handling

We can group PlatformHub errors into 2 categories, policy errors and other runtime checks.

Policy Exceptions

In PlatformHub's initialisation phase, policy definitions in policy files are parsed and checked for their validity. If validation fails, then initialisation is skipped and PlatformHub raises one of the following exceptions.

Plugin Name Format

  • All plugin names should be pascalcase, otherwise PlatformHub will raise an InvalidPluginName exception.
json
{
    "name": "ExamplePlugin",
    "version": "0.1",
    ...
}
  • A plugin name should be same as its class name, otherwise PlatformHub will raise an InvalidPluginName exception.

Message Name Format

  • A message name should not be empty, otherwise PlatformHub will raise an InvalidMessageName exception.
json
{
    "publish": {
        "eventStreams": [
            {
                "messageName": "",
                "pluginName": "ExamplePlugin"
            }
        ]
    },
}
  • Message name must also be pascal case to conform to the naming convention. Following example will raise InvalidMessageName.
json
{
    "publish": {
        "eventStreams": [
            {
                "messageName": "invalidmessagename",
                "pluginName": "ExamplePlugin"
            }
        ]
    },
}

No Overlap In Published And Subscribed Messages

  • A plugin cannot subscribe or receive the same message as it publishes or sends. Following example will raise a MessageSubscribedAndPublishedException.
json
{
    "publish": {
        "eventStreams": [
            {
                "messageName": "ExampleMessage",
                "pluginName": "ExamplePlugin"
            }
        ]
    },
    "subscribeOnStartup": {
        "eventStreams": [
            {
                "messageName": "ExampleMessage",
                "pluginName": "ExamplePlugin"
            }
        ]
    }
}

Plugin Is Unused

  • In the case where a plugin's outgoing messages don't have any receivers or subscribers, or it doesn't receive or subscribe to any incoming messages from other plugins. PlatformHub will raise a UnusedPluginException

Duplicate Messages or Plugin Names

  • Plugins policy file cannot contain duplicate messages, otherwise PlatformHub will raise a DuplicateMessageException
  • Two plugins cannot have the same name.

Message Owner For Send and Subscribe

  • Each message definition should have an owner in policy. Following example will raise InvalidMessageName as message owner is undefined for ExampleMessage. It only applys to send messages and event subscriptions.
json
{
    "subscribeOnStartup": {
        "eventStreams": [
            {
                "messageName": "ExampleMessage",
                "pluginName": ""
            }
        ]
    }
}

Other Runtime Errors

Platformhub Uninitialised

These errors happens whilst attempting to send a message but microkernel is not initialised yet. Platformhub rasies MicroKernelUninitializedException exception to show Platformhub is not ready yet to handle the message.

Unauthorized Message Exception

This happens when a sender is not entitled to send a message. Platformhub raises UnauthorizedMessageException.

Message Receiver Not Found

This happens when a message has no receiver. Platformhub raises MessageReceiverNotFoundException.

Multiple Message Receiver

In case of registering multiple recipients for same message, Platformhub raises MessageMultiRecipientException. This only applies to direct messages (Command/Query/Navigation).