protected function resolveErrorAsArray(RequestApplicationInterface $app, \Throwable $exception)
    {
        $data = $this->getErrorData($exception);
        $responseData = ['error' => $data];
        $app->response->setBody($responseData)->setStatusCodeByException($exception);
        return $app->response;
    }