Error action

Extbase offers an out of the box handling for errors. Errors might occur during the mapping of incoming action arguments. E.g., an argument can not be mapped or validation did not pass.

How it works

  1. Extbase will try to map all arguments within ActionController. During this process arguments will also be validated.
  2. If an error occurred, the class will call the $this->errorMethodName instead of determined $this->actionMethodName.
  3. The default is to call errorAction() which will:
    1. Clear cache in case persistence.enableAutomaticCacheClearing is activated and current scope is frontend.
    2. Add an error Flash Message by calling addErrorFlashMessage(). Which in turn will call getErrorFlashMessage() to retrieve the message to show.
    3. Forward back to referring request. If no referrer exists, a plain text message will be displayed, fetched from getFlattenedValidationErrorMessage().

Overloading behavior

Each of the above steps can be adjusted by implementing custom methods or replacing values within properties. All of the above is protected and, therefore, can be replaced.

errorMethodName property

Replacing the default value errorAction will result in a different method to be called in case of an error.

errorAction() method

Replacing the default implementation can be used to define custom error handling. E.g., the requested format could be checked, and a prepared JSON result could be returned.

getErrorFlashMessage() method

It can be replaced to return false to prevent the generation of a flash message. It can also return any other custom string which will be placed inside the generated flash message.

getFlattenedValidationErrorMessage() method

Can be replaced in order to display some other error message if no referrer exists.