Skip to content

Commit 06937bc

Browse files
committed
rewrite to return early
1 parent 8c767eb commit 06937bc

1 file changed

Lines changed: 4 additions & 6 deletions

File tree

libs/diag/sdk_error.go

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,12 @@ func findApiErr(e error) *apierr.APIError {
2626
}
2727

2828
func FormatAPIErrorSummary(e error) string {
29-
extra := ""
3029
apiErr := findApiErr(e)
31-
if apiErr != nil {
32-
extra = strings.TrimSpace(fmt.Sprintf("%d %s", apiErr.StatusCode, apiErr.ErrorCode))
33-
extra = " (" + extra + ")"
30+
if apiErr == nil {
31+
return e.Error()
3432
}
35-
36-
return e.Error() + extra
33+
extra := strings.TrimSpace(fmt.Sprintf("%d %s", apiErr.StatusCode, apiErr.ErrorCode))
34+
return e.Error() + " (" + extra + ")"
3735
}
3836

3937
func FormatAPIErrorDetails(e error) string {

0 commit comments

Comments
 (0)