Skip to content

Commit

Permalink
Fix misc issues
Browse files Browse the repository at this point in the history
  • Loading branch information
raphael committed Jul 3, 2024
1 parent 9c1f9cf commit 42cb425
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions codegen/example/templates/server_handler.go.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@
}
}
if !{{ .VarName }}Seen {
log.Fatalf(ctx, "invalid value for URL '{{ .Name }}' variable: %q (valid values: {{ join .Values "," }})\n", *{{ .VarName }}F)
log.Fatal(ctx, fmt.Errorf("invalid value for URL '{{ .Name }}' variable: %q (valid values: {{ join .Values "," }})\n", *{{ .VarName }}F))
}
{{- end }}
addr = strings.Replace(addr, "{{ printf "{%s}" .Name }}", *{{ .VarName }}F, -1)
{{- end }}
u, err := url.Parse(addr)
if err != nil {
log.Fatalf(ctx, "invalid URL %#v: %s\n", addr, err)
log.Fatalf(ctx, err, "invalid URL %#v\n", addr)
}
if *secureF {
u.Scheme = "{{ $u.Transport.Type }}s"
Expand All @@ -38,7 +38,7 @@
if *{{ $u.Transport.Type }}PortF != "" {
h, _, err := net.SplitHostPort(u.Host)
if err != nil {
log.Fatalf(ctx, "invalid URL %#v: %s\n", u.Host, err)
log.Fatalf(ctx, err, "invalid URL %#v\n", u.Host)
}
u.Host = net.JoinHostPort(h, *{{ $u.Transport.Type }}PortF)
} else if u.Port() == "" {
Expand All @@ -50,5 +50,5 @@
{{ end }}
{{- end }}
default:
log.Fatalf(ctx, "invalid host argument: %q (valid hosts: {{ join .Server.AvailableHosts "|" }})\n", *hostF)
log.Fatal(ctx, fmt.Errorf("invalid host argument: %q (valid hosts: {{ join .Server.AvailableHosts "|" }})\n", *hostF))
}

0 comments on commit 42cb425

Please sign in to comment.