Last active
December 20, 2022 13:23
-
-
Save warlock/d3d786f4589ddd27078faa228e869468 to your computer and use it in GitHub Desktop.
Gestió d'errors Go
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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