Plugin to amend HTTP Response Message on Exit

I am trying to get a plugin to amend the HTTP response message for a number of different error codes.

I am trying to understand how to replace the message as the kong.response.exit method is throwing an error on body/header filters.

The plugin is running with a priority of 20000 so it is the last one to run.

Help and corrections please.


Please read the documentation for the method:

You cannot invoke it in the body_filter phase because the response code and HTTP headers are already sent to the client by then.