{"action":"created","issue":{"url":"https://api.github.com/repos/laravel/lumen-framework/issues/479","repository_url":"https://api.github.com/repos/laravel/lumen-framework","labels_url":"https://api.github.com/repos/laravel/lumen-framework/issues/479/labels{/name}","comments_url":"https://api.github.com/repos/laravel/lumen-framework/issues/479/comments","events_url":"https://api.github.com/repos/laravel/lumen-framework/issues/479/events","html_url":"https://github.com/laravel/lumen-framework/pull/479","id":176770358,"number":479,"title":"Message on NotFoundHttpException and MethodNotAllowedHttpException","user":{"login":"astasoft","id":469847,"avatar_url":"https://avatars.githubusercontent.com/u/469847?v=3","gravatar_id":"","url":"https://api.github.com/users/astasoft","html_url":"https://github.com/astasoft","followers_url":"https://api.github.com/users/astasoft/followers","following_url":"https://api.github.com/users/astasoft/following{/other_user}","gists_url":"https://api.github.com/users/astasoft/gists{/gist_id}","starred_url":"https://api.github.com/users/astasoft/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/astasoft/subscriptions","organizations_url":"https://api.github.com/users/astasoft/orgs","repos_url":"https://api.github.com/users/astasoft/repos","events_url":"https://api.github.com/users/astasoft/events{/privacy}","received_events_url":"https://api.github.com/users/astasoft/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2016-09-13T22:48:00Z","updated_at":"2016-09-14T06:41:03Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/laravel/lumen-framework/pulls/479","html_url":"https://github.com/laravel/lumen-framework/pull/479","diff_url":"https://github.com/laravel/lumen-framework/pull/479.diff","patch_url":"https://github.com/laravel/lumen-framework/pull/479.patch"},"body":"## Overview\r\n\r\nThis PR add message when NotFoundHttpException and MethodNotAllowedHttpException exceptions are thrown.\r\n\r\n## Problem\r\n\r\nI'm creating an application using Lumen and trying to develop using [Programming by Wishful Thinking](http://sam-serpoosh.github.io/wishful-thinking/) approach which also involving TDD. Problem comes when I started to create non-existent route which part of my wishful and run the unit test via phpunit.\r\n\r\nThe error message did not tell me which was causing the problem because:\r\n1. Lumen convert all errors into HTTP response even when called from CLI.\r\n2. Even when I throw the error manually to overcome issue number 1 by editing app/Exceptions/Handler.php it still gives me no error message about what was wrong.\r\n\r\nHere's my app/Exceptions/Handler.php\r\n```\r\n    /**\r\n     * Render an exception into an HTTP response.\r\n     *\r\n     * @param  \\Illuminate\\Http\\Request  $request\r\n     * @param  \\Exception  $e\r\n     * @return \\Illuminate\\Http\\Response\r\n     */\r\n    public function render($request, Exception $e)\r\n    {\r\n        if (env('APP_DEBUG')) {\r\n            $error = sprintf(\"%s\\nFile: %s\\n (Line: %s)\\nCall Stack:\\n%s\",\r\n                            $e->getMessage(),\r\n                            $e->getFile(),\r\n                            $e->getLine(),\r\n                            $e->getTraceAsString());\r\n            throw new Exception($error, $e->getCode());\r\n        }\r\n\r\n        if ($request->isJson()) {\r\n            return response()->json([\r\n                'code' => $e->getCode(),\r\n                'status' => 'error',\r\n                'message' => $e->getMessage(),\r\n                'data' => $e->getTrace()\r\n            ]);\r\n        }\r\n\r\n        return parent::render($request, $e);\r\n    }\r\n```\r\n\r\n## Solution\r\n\r\nThrow more meaningful message when non existent route or not allowed method, so it is easier to debug when using TDD on CLI. "},"comment":{"url":"https://api.github.com/repos/laravel/lumen-framework/issues/comments/246920416","html_url":"https://github.com/laravel/lumen-framework/pull/479#issuecomment-246920416","issue_url":"https://api.github.com/repos/laravel/lumen-framework/issues/479","id":246920416,"user":{"login":"GrahamCampbell","id":2829600,"avatar_url":"https://avatars.githubusercontent.com/u/2829600?v=3","gravatar_id":"","url":"https://api.github.com/users/GrahamCampbell","html_url":"https://github.com/GrahamCampbell","followers_url":"https://api.github.com/users/GrahamCampbell/followers","following_url":"https://api.github.com/users/GrahamCampbell/following{/other_user}","gists_url":"https://api.github.com/users/GrahamCampbell/gists{/gist_id}","starred_url":"https://api.github.com/users/GrahamCampbell/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/GrahamCampbell/subscriptions","organizations_url":"https://api.github.com/users/GrahamCampbell/orgs","repos_url":"https://api.github.com/users/GrahamCampbell/repos","events_url":"https://api.github.com/users/GrahamCampbell/events{/privacy}","received_events_url":"https://api.github.com/users/GrahamCampbell/received_events","type":"User","site_admin":false},"created_at":"2016-09-14T06:41:03Z","updated_at":"2016-09-14T06:41:03Z","body":"Exception messages should not reveal internals to users. 👎 "}}
{"actor":{"display_login":"GrahamCampbell"}}