|
@@ -14,20 +14,19 @@ func main() {
|
|
|
}
|
|
|
|
|
|
// checkErr prints the error message and exits the program if the message is not nil.
|
|
|
-func checkErr(msg any) {
|
|
|
- if msg == nil {
|
|
|
+func checkErr(err any) {
|
|
|
+ if err == nil {
|
|
|
return
|
|
|
}
|
|
|
|
|
|
- if errorResponse, ok := msg.(api.ErrorResponse); ok {
|
|
|
- // This error contains some additional information that we want to print
|
|
|
- fmt.Fprintln(os.Stderr, "Error: ", errorResponse.Err)
|
|
|
- if errorResponse.Hint != "" {
|
|
|
- fmt.Fprintf(os.Stderr, "\n%s\n", errorResponse.Hint)
|
|
|
+ switch e := err.(type) {
|
|
|
+ case api.ErrorResponse:
|
|
|
+ fmt.Fprintln(os.Stderr, "Error: ", e.Err)
|
|
|
+ if e.Hint != "" {
|
|
|
+ fmt.Fprintf(os.Stderr, "\n%s\n", e.Hint)
|
|
|
}
|
|
|
- os.Exit(1)
|
|
|
+ default:
|
|
|
+ fmt.Fprintln(os.Stderr, "Error: ", err)
|
|
|
}
|
|
|
-
|
|
|
- fmt.Fprintln(os.Stderr, "Error: ", msg)
|
|
|
os.Exit(1)
|
|
|
}
|