Skip to content

Instantly share code, notes, and snippets.

@warlock
Last active December 20, 2022 13:23
Show Gist options
  • Save warlock/d3d786f4589ddd27078faa228e869468 to your computer and use it in GitHub Desktop.
Save warlock/d3d786f4589ddd27078faa228e869468 to your computer and use it in GitHub Desktop.
Gestió d'errors Go
var codeErr pq.Error
if errors.As(err, &codeErr) {
if codeErr.Code == "unique_violation" {
handleError(w, http.StatusInternalServerError, errors.New("order exists"))
return
}
}
var codeErr *jsonrpc.RPCError
if errors.As(err, &codeErr) {
fmt.Println(codeErr.Message)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment