{"action":"created","issue":{"url":"https://api.github.com/repos/labstack/echo/issues/67","labels_url":"https://api.github.com/repos/labstack/echo/issues/67/labels{/name}","comments_url":"https://api.github.com/repos/labstack/echo/issues/67/comments","events_url":"https://api.github.com/repos/labstack/echo/issues/67/events","html_url":"https://github.com/labstack/echo/issues/67","id":77770231,"number":67,"title":"why HTTPError as return from HandlerFunc?","user":{"login":"tve","id":39480,"avatar_url":"https://avatars.githubusercontent.com/u/39480?v=3","gravatar_id":"","url":"https://api.github.com/users/tve","html_url":"https://github.com/tve","followers_url":"https://api.github.com/users/tve/followers","following_url":"https://api.github.com/users/tve/following{/other_user}","gists_url":"https://api.github.com/users/tve/gists{/gist_id}","starred_url":"https://api.github.com/users/tve/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tve/subscriptions","organizations_url":"https://api.github.com/users/tve/orgs","repos_url":"https://api.github.com/users/tve/repos","events_url":"https://api.github.com/users/tve/events{/privacy}","received_events_url":"https://api.github.com/users/tve/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/labstack/echo/labels/question","name":"question","color":"cc317c"}],"state":"closed","locked":false,"assignee":{"login":"vishr","id":314036,"avatar_url":"https://avatars.githubusercontent.com/u/314036?v=3","gravatar_id":"","url":"https://api.github.com/users/vishr","html_url":"https://github.com/vishr","followers_url":"https://api.github.com/users/vishr/followers","following_url":"https://api.github.com/users/vishr/following{/other_user}","gists_url":"https://api.github.com/users/vishr/gists{/gist_id}","starred_url":"https://api.github.com/users/vishr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vishr/subscriptions","organizations_url":"https://api.github.com/users/vishr/orgs","repos_url":"https://api.github.com/users/vishr/repos","events_url":"https://api.github.com/users/vishr/events{/privacy}","received_events_url":"https://api.github.com/users/vishr/received_events","type":"User","site_admin":false},"milestone":null,"comments":7,"created_at":"2015-05-18T19:12:36Z","updated_at":"2015-05-20T15:33:29Z","closed_at":"2015-05-18T20:35:32Z","body":"Why did you make the breaking change to require HandlerFunc to return *HTTPError instead of error? Why not make HTTPError implement the Error() method and then it can be passed as error? This way a handler could either return a plain error or an HTTPError."},"comment":{"url":"https://api.github.com/repos/labstack/echo/issues/comments/103927619","html_url":"https://github.com/labstack/echo/issues/67#issuecomment-103927619","issue_url":"https://api.github.com/repos/labstack/echo/issues/67","id":103927619,"user":{"login":"vishr","id":314036,"avatar_url":"https://avatars.githubusercontent.com/u/314036?v=3","gravatar_id":"","url":"https://api.github.com/users/vishr","html_url":"https://github.com/vishr","followers_url":"https://api.github.com/users/vishr/followers","following_url":"https://api.github.com/users/vishr/following{/other_user}","gists_url":"https://api.github.com/users/vishr/gists{/gist_id}","starred_url":"https://api.github.com/users/vishr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vishr/subscriptions","organizations_url":"https://api.github.com/users/vishr/orgs","repos_url":"https://api.github.com/users/vishr/repos","events_url":"https://api.github.com/users/vishr/events{/privacy}","received_events_url":"https://api.github.com/users/vishr/received_events","type":"User","site_admin":false},"created_at":"2015-05-20T15:33:29Z","updated_at":"2015-05-20T15:33:29Z","body":"@raphael If you look at the end of the post, the author mentions about returning appError in cases like this:\r\n\r\n```go\r\ntype appError struct {\r\n    Error   error\r\n    Message string\r\n    Code    int\r\n}\r\n```\r\n> (It's usually a mistake to pass back the concrete type of an error rather than error, for reasons discussed in the Go FAQ, but it's the right thing to do here because ServeHTTP is the only place that sees the value and uses its contents.)\r\n\r\n> And make `appHandler`'s ServeHTTP method display the `appError`'s Message to the user with the correct HTTP status Code and log the full Error to the developer console:\r\n\r\nWith `HTTPError` in the signature handler signature it brings a good convention. For instance, if all handlers start sending any error (As they don't know about `HTTPError`) then the default centralized HTTP error handler won't be of much use, turning everything into `500`.\r\n\r\nReturning `HTTPError` is very easy with default error, just wrap it like this `&HTTPError{Error: err}`\r\n\r\nNothing is set in stone, I am open for discussion.\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n"}}