RoastSoftware/roaster

Handle errors for Roast Me! (home page)

Closed this issue · 0 comments

wstrm commented

Errors are not handled what so ever, handle them?!

Example error that we've got when spamming with too large code snippets (it should also return a Request Entity Too Large, and not Internal Server Error):

[�[34mroasterd�[0m] 2018/12/30 18:04:36 handler.go:35: handler error (500: Internal Server Error):  (failed to insert Roast for username: 'rövhål91': pq: new row for relation "roast" violates check constraint "code_chk"
github.com/willeponken/causerr.New
	/go/pkg/mod/github.com/willeponken/causerr@v0.0.0-20181211111524-d6ebaef15707/causerr.go:61
github.com/LuleaUniversityOfTechnology/2018-project-roaster/router/route.analyzeCode
	/usr/src/roaster/router/route/roast.go:56
github.com/LuleaUniversityOfTechnology/2018-project-roaster/router/route.handler.ServeHTTP
	/usr/src/roaster/router/route/handler.go:30
github.com/LuleaUniversityOfTechnology/2018-project-roaster/middleware.EnforceContentType.func1.1
	/usr/src/roaster/middleware/contenttype.go:28
net/http.HandlerFunc.ServeHTTP
	/usr/local/go/src/net/http/server.go:1964
github.com/gorilla/handlers.ContentTypeHandler.func1
	/go/pkg/mod/github.com/gorilla/handlers@v1.4.0/handlers.go:134
net/http.HandlerFunc.ServeHTTP
	/usr/local/go/src/net/http/server.go:1964
github.com/LuleaUniversityOfTechnology/2018-project-roaster/middleware.CSRF.func1.1
	/usr/src/roaster/middleware/csrf.go:23
net/http.HandlerFunc.ServeHTTP
	/usr/local/go/src/net/http/server.go:1964
github.com/gorilla/csrf.(*csrf).ServeHTTP
	/go/pkg/mod/github.com/gorilla/csrf@v1.5.1/csrf.go:267
github.com/gorilla/handlers.(*cors).ServeHTTP
	/go/pkg/mod/github.com/gorilla/handlers@v1.4.0/cors.go:52
github.com/gorilla/mux.(*Router).ServeHTTP
	/go/pkg/mod/github.com/gorilla/mux@v1.6.2/mux.go:162
github.com/LuleaUniversityOfTechnology/2018-project-roaster/middleware.Redirect.func1
	/usr/src/roaster/middleware/redirect.go:26
net/http.HandlerFunc.ServeHTTP
	/usr/local/go/src/net/http/server.go:1964
github.com/gorilla/handlers.recoveryHandler.ServeHTTP
	/go/pkg/mod/github.com/gorilla/handlers@v1.4.0/recovery.go:78
github.com/gorilla/handlers.(*recoveryHandler).ServeHTTP
	<autogenerated>:1
net/http.serverHandler.ServeHTTP
	/usr/local/go/src/net/http/server.go:2741
net/http.(*conn).serve
	/usr/local/go/src/net/http/server.go:1847
runtime.goexit
	/usr/local/go/src/runtime/asm_amd64.s:1333)
[�[34mroasterd�[0m] 2018/12/30 18:04:36 handler.go:35: handler error (500: Internal Server Error):  (failed to insert Roast for username: 'rövhål91': pq: new row for relation "roast" violates check constraint "code_chk"
github.com/willeponken/causerr.New
	/go/pkg/mod/github.com/willeponken/causerr@v0.0.0-20181211111524-d6ebaef15707/causerr.go:61
github.com/LuleaUniversityOfTechnology/2018-project-roaster/router/route.analyzeCode
	/usr/src/roaster/router/route/roast.go:56
github.com/LuleaUniversityOfTechnology/2018-project-roaster/router/route.handler.ServeHTTP
	/usr/src/roaster/router/route/handler.go:30
github.com/LuleaUniversityOfTechnology/2018-project-roaster/middleware.EnforceContentType.func1.1
	/usr/src/roaster/middleware/contenttype.go:28
net/http.HandlerFunc.ServeHTTP
	/usr/local/go/src/net/http/server.go:1964
github.com/gorilla/handlers.ContentTypeHandler.func1
	/go/pkg/mod/github.com/gorilla/handlers@v1.4.0/handlers.go:134
net/http.HandlerFunc.ServeHTTP
	/usr/local/go/src/net/http/server.go:1964
github.com/LuleaUniversityOfTechnology/2018-project-roaster/middleware.CSRF.func1.1
	/usr/src/roaster/middleware/csrf.go:23
net/http.HandlerFunc.ServeHTTP
	/usr/local/go/src/net/http/server.go:1964
github.com/gorilla/csrf.(*csrf).ServeHTTP
	/go/pkg/mod/github.com/gorilla/csrf@v1.5.1/csrf.go:267
github.com/gorilla/handlers.(*cors).ServeHTTP
	/go/pkg/mod/github.com/gorilla/handlers@v1.4.0/cors.go:52
github.com/gorilla/mux.(*Router).ServeHTTP
	/go/pkg/mod/github.com/gorilla/mux@v1.6.2/mux.go:162
github.com/LuleaUniversityOfTechnology/2018-project-roaster/middleware.Redirect.func1
	/usr/src/roaster/middleware/redirect.go:26
net/http.HandlerFunc.ServeHTTP
	/usr/local/go/src/net/http/server.go:1964
github.com/gorilla/handlers.recoveryHandler.ServeHTTP
	/go/pkg/mod/github.com/gorilla/handlers@v1.4.0/recovery.go:78
github.com/gorilla/handlers.(*recoveryHandler).ServeHTTP
	<autogenerated>:1
net/http.serverHandler.ServeHTTP
	/usr/local/go/src/net/http/server.go:2741
net/http.(*conn).serve
	/usr/local/go/src/net/http/server.go:1847
runtime.goexit
	/usr/local/go/src/runtime/asm_amd64.s:1333)
[�[34mroasterd�[0m] 2018/12/30 18:04:36 handler.go:35: handler error (500: Internal Server Error):  (failed to insert Roast for username: 'rövhål91': pq: new row for relation "roast" violates check constraint "code_chk"
github.com/willeponken/causerr.New
	/go/pkg/mod/github.com/willeponken/causerr@v0.0.0-20181211111524-d6ebaef15707/causerr.go:61
github.com/LuleaUniversityOfTechnology/2018-project-roaster/router/route.analyzeCode
	/usr/src/roaster/router/route/roast.go:56
github.com/LuleaUniversityOfTechnology/2018-project-roaster/router/route.handler.ServeHTTP
	/usr/src/roaster/router/route/handler.go:30
github.com/LuleaUniversityOfTechnology/2018-project-roaster/middleware.EnforceContentType.func1.1
	/usr/src/roaster/middleware/contenttype.go:28
net/http.HandlerFunc.ServeHTTP
	/usr/local/go/src/net/http/server.go:1964
github.com/gorilla/handlers.ContentTypeHandler.func1
	/go/pkg/mod/github.com/gorilla/handlers@v1.4.0/handlers.go:134
net/http.HandlerFunc.ServeHTTP
	/usr/local/go/src/net/http/server.go:1964
github.com/LuleaUniversityOfTechnology/2018-project-roaster/middleware.CSRF.func1.1
	/usr/src/roaster/middleware/csrf.go:23
net/http.HandlerFunc.ServeHTTP
	/usr/local/go/src/net/http/server.go:1964
github.com/gorilla/csrf.(*csrf).ServeHTTP
	/go/pkg/mod/github.com/gorilla/csrf@v1.5.1/csrf.go:267
github.com/gorilla/handlers.(*cors).ServeHTTP
	/go/pkg/mod/github.com/gorilla/handlers@v1.4.0/cors.go:52
github.com/gorilla/mux.(*Router).ServeHTTP
	/go/pkg/mod/github.com/gorilla/mux@v1.6.2/mux.go:162
github.com/LuleaUniversityOfTechnology/2018-project-roaster/middleware.Redirect.func1
	/usr/src/roaster/middleware/redirect.go:26
net/http.HandlerFunc.ServeHTTP
	/usr/local/go/src/net/http/server.go:1964
github.com/gorilla/handlers.recoveryHandler.ServeHTTP
	/go/pkg/mod/github.com/gorilla/handlers@v1.4.0/recovery.go:78
github.com/gorilla/handlers.(*recoveryHandler).ServeHTTP
	<autogenerated>:1
net/http.serverHandler.ServeHTTP
	/usr/local/go/src/net/http/server.go:2741
net/http.(*conn).serve
	/usr/local/go/src/net/http/server.go:1847
runtime.goexit
	/usr/local/go/src/runtime/asm_amd64.s:1333)
[�[34mroasterd�[0m] 2018/12/30 18:04:36 handler.go:35: handler error (500: Internal Server Error):  (failed to insert Roast for username: 'rövhål91': pq: new row for relation "roast" violates check constraint "code_chk"
github.com/willeponken/causerr.New
	/go/pkg/mod/github.com/willeponken/causerr@v0.0.0-20181211111524-d6ebaef15707/causerr.go:61
github.com/LuleaUniversityOfTechnology/2018-project-roaster/router/route.analyzeCode
	/usr/src/roaster/router/route/roast.go:56
github.com/LuleaUniversityOfTechnology/2018-project-roaster/router/route.handler.ServeHTTP
	/usr/src/roaster/router/route/handler.go:30
github.com/LuleaUniversityOfTechnology/2018-project-roaster/middleware.EnforceContentType.func1.1
	/usr/src/roaster/middleware/contenttype.go:28
net/http.HandlerFunc.ServeHTTP
	/usr/local/go/src/net/http/server.go:1964
github.com/gorilla/handlers.ContentTypeHandler.func1
	/go/pkg/mod/github.com/gorilla/handlers@v1.4.0/handlers.go:134
net/http.HandlerFunc.ServeHTTP
	/usr/local/go/src/net/http/server.go:1964
github.com/LuleaUniversityOfTechnology/2018-project-roaster/middleware.CSRF.func1.1
	/usr/src/roaster/middleware/csrf.go:23
net/http.HandlerFunc.ServeHTTP
	/usr/local/go/src/net/http/server.go:1964
github.com/gorilla/csrf.(*csrf).ServeHTTP
	/go/pkg/mod/github.com/gorilla/csrf@v1.5.1/csrf.go:267
github.com/gorilla/handlers.(*cors).ServeHTTP
	/go/pkg/mod/github.com/gorilla/handlers@v1.4.0/cors.go:52
github.com/gorilla/mux.(*Router).ServeHTTP
	/go/pkg/mod/github.com/gorilla/mux@v1.6.2/mux.go:162
github.com/LuleaUniversityOfTechnology/2018-project-roaster/middleware.Redirect.func1
	/usr/src/roaster/middleware/redirect.go:26
net/http.HandlerFunc.ServeHTTP
	/usr/local/go/src/net/http/server.go:1964
github.com/gorilla/handlers.recoveryHandler.ServeHTTP
	/go/pkg/mod/github.com/gorilla/handlers@v1.4.0/recovery.go:78
github.com/gorilla/handlers.(*recoveryHandler).ServeHTTP
	<autogenerated>:1
net/http.serverHandler.ServeHTTP
	/usr/local/go/src/net/http/server.go:2741
net/http.(*conn).serve
	/usr/local/go/src/net/http/server.go:1847
runtime.goexit
	/usr/local/go/src/runtime/asm_amd64.s:1333)
[�[34mroasterd�[0m] 2018/12/30 18:04:36 handler.go:35: handler error (500: Internal Server Error):  (failed to insert Roast for username: 'rövhål91': pq: new row for relation "roast" violates check constraint "code_chk"
github.com/willeponken/causerr.New
	/go/pkg/mod/github.com/willeponken/causerr@v0.0.0-20181211111524-d6ebaef15707/causerr.go:61
github.com/LuleaUniversityOfTechnology/2018-project-roaster/router/route.analyzeCode
	/usr/src/roaster/router/route/roast.go:56
github.com/LuleaUniversityOfTechnology/2018-project-roaster/router/route.handler.ServeHTTP
	/usr/src/roaster/router/route/handler.go:30
github.com/LuleaUniversityOfTechnology/2018-project-roaster/middleware.EnforceContentType.func1.1
	/usr/src/roaster/middleware/contenttype.go:28
net/http.HandlerFunc.ServeHTTP
	/usr/local/go/src/net/http/server.go:1964
github.com/gorilla/handlers.ContentTypeHandler.func1
	/go/pkg/mod/github.com/gorilla/handlers@v1.4.0/handlers.go:134
net/http.HandlerFunc.ServeHTTP
	/usr/local/go/src/net/http/server.go:1964
github.com/LuleaUniversityOfTechnology/2018-project-roaster/middleware.CSRF.func1.1
	/usr/src/roaster/middleware/csrf.go:23
net/http.HandlerFunc.ServeHTTP
	/usr/local/go/src/net/http/server.go:1964
github.com/gorilla/csrf.(*csrf).ServeHTTP
	/go/pkg/mod/github.com/gorilla/csrf@v1.5.1/csrf.go:267
github.com/gorilla/handlers.(*cors).ServeHTTP
	/go/pkg/mod/github.com/gorilla/handlers@v1.4.0/cors.go:52
github.com/gorilla/mux.(*Router).ServeHTTP
	/go/pkg/mod/github.com/gorilla/mux@v1.6.2/mux.go:162
github.com/LuleaUniversityOfTechnology/2018-project-roaster/middleware.Redirect.func1
	/usr/src/roaster/middleware/redirect.go:26
net/http.HandlerFunc.ServeHTTP
	/usr/local/go/src/net/http/server.go:1964
github.com/gorilla/handlers.recoveryHandler.ServeHTTP
	/go/pkg/mod/github.com/gorilla/handlers@v1.4.0/recovery.go:78
github.com/gorilla/handlers.(*recoveryHandler).ServeHTTP
	<autogenerated>:1
net/http.serverHandler.ServeHTTP
	/usr/local/go/src/net/http/server.go:2741
net/http.(*conn).serve
	/usr/local/go/src/net/http/server.go:1847
runtime.goexit
	/usr/local/go/src/runtime/asm_amd64.s:1333)
[�[34mroasterd�[0m] 2018/12/30 18:04:36 handler.go:35: handler error (500: Internal Server Error):  (failed to insert Roast for username: 'rövhål91': pq: new row for relation "roast" violates check constraint "code_chk"
github.com/willeponken/causerr.New
	/go/pkg/mod/github.com/willeponken/causerr@v0.0.0-20181211111524-d6ebaef15707/causerr.go:61
github.com/LuleaUniversityOfTechnology/2018-project-roaster/router/route.analyzeCode
	/usr/src/roaster/router/route/roast.go:56
github.com/LuleaUniversityOfTechnology/2018-project-roaster/router/route.handler.ServeHTTP
	/usr/src/roaster/router/route/handler.go:30
github.com/LuleaUniversityOfTechnology/2018-project-roaster/middleware.EnforceContentType.func1.1
	/usr/src/roaster/middleware/contenttype.go:28
net/http.HandlerFunc.ServeHTTP
	/usr/local/go/src/net/http/server.go:1964
github.com/gorilla/handlers.ContentTypeHandler.func1
	/go/pkg/mod/github.com/gorilla/handlers@v1.4.0/handlers.go:134
net/http.HandlerFunc.ServeHTTP
	/usr/local/go/src/net/http/server.go:1964
github.com/LuleaUniversityOfTechnology/2018-project-roaster/middleware.CSRF.func1.1
	/usr/src/roaster/middleware/csrf.go:23
net/http.HandlerFunc.ServeHTTP
	/usr/local/go/src/net/http/server.go:1964
github.com/gorilla/csrf.(*csrf).ServeHTTP
	/go/pkg/mod/github.com/gorilla/csrf@v1.5.1/csrf.go:267
github.com/gorilla/handlers.(*cors).ServeHTTP
	/go/pkg/mod/github.com/gorilla/handlers@v1.4.0/cors.go:52
github.com/gorilla/mux.(*Router).ServeHTTP
	/go/pkg/mod/github.com/gorilla/mux@v1.6.2/mux.go:162
github.com/LuleaUniversityOfTechnology/2018-project-roaster/middleware.Redirect.func1
	/usr/src/roaster/middleware/redirect.go:26
net/http.HandlerFunc.ServeHTTP
	/usr/local/go/src/net/http/server.go:1964
github.com/gorilla/handlers.recoveryHandler.ServeHTTP
	/go/pkg/mod/github.com/gorilla/handlers@v1.4.0/recovery.go:78
github.com/gorilla/handlers.(*recoveryHandler).ServeHTTP
	<autogenerated>:1
net/http.serverHandler.ServeHTTP
	/usr/local/go/src/net/http/server.go:2741
net/http.(*conn).serve
	/usr/local/go/src/net/http/server.go:1847
runtime.goexit
	/usr/local/go/src/runtime/asm_amd64.s:1333)