phalcon/cphalcon · error · Phalcon\Mvc\Micro\Exceptions\ResponseHandlerNotCallable

Response handler is not callable or is not defined

Error message

Response handler is not callable or is not defined

What it means

Thrown in the finishing phase of Micro::handle when a response handler is registered ($this->responseHandler via Micro::responseHandler) but its value is not callable. After the route handler (or error path) produced a return value, Micro wants to pass it through the custom response handler; the guard pre-validates that the stored handler can actually be invoked, failing with this sentinel error when the configuration is wrong.

Solutions

  1. Pass a callable to $app->responseHandler()
  2. Or clear the response handler to use the default response behavior
Defensive patterns

Strategy: type-guard

When it happens

Trigger: Thrown at phalcon/Mvc/Micro.zep:711 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of phalcon/cphalcon@b7419de9cd (2026-08-21). Data as JSON: /api/errors/415d097dd405055c. Report an issue: GitHub.

Appendix: source

Thrown at phalcon/Mvc/Micro.zep:711

                } else {
                    if returnedValue !== false {
                        throw e;
                    }
                }
            } else {
                if returnedValue !== false {
                    throw e;
                }
            }
        }

        /**
         * Check if a response handler is defined, else use default response
         * handler
         */
        if this->responseHandler {
            if unlikely !is_callable(this->responseHandler) {
                throw new ResponseHandlerNotCallable();
            }

            let returnedValue = call_user_func(this->responseHandler);
        } else {
            /**
             * Check if the returned value is a string and take it as response
             * body
             */
            if typeof returnedValue === "string" {
                let response = <ResponseInterface> container->getShared("response");

                if !response->isSent() {
                    response->setContent(returnedValue);
                    response->send();
                }
            }

            /**

View on GitHub (pinned to b7419de9cd)