Skip to content

Commit

Permalink
Improve error messages (#75)
Browse files Browse the repository at this point in the history
* Improve error messages

* Regenerate examples
  • Loading branch information
VojtechVitek authored Nov 6, 2024
1 parent 27970f3 commit a3b0544
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions _examples/golang-basics/example.gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions _examples/golang-imports/api.gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions server.go.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,14 @@ func (s *{{$serviceName}}) ServeHTTP(w http.ResponseWriter, r *http.Request) {
handler = s.serve{{$method.Name | firstLetterToUpper}}JSON{{if $method.StreamOutput}}Stream{{end}}
{{- end}}
default:
err := ErrWebrpcBadRoute.WithCausef("no WebRPC method defined for path %v", r.URL.Path)
err := ErrWebrpcBadRoute.WithCausef("no webrpc method defined for path %v", r.URL.Path)
s.sendErrorJSON(w, r, err)
return
}

if r.Method != "POST" {
w.Header().Add("Allow", "POST") // RFC 9110.
err := ErrWebrpcBadMethod.WithCausef("unsupported method %v (only POST is allowed)", r.Method)
err := ErrWebrpcBadMethod.WithCausef("unsupported HTTP method %v (only POST is allowed)", r.Method)
s.sendErrorJSON(w, r, err)
return
}
Expand Down

0 comments on commit a3b0544

Please sign in to comment.