In many situations, while testing we encounter ErrInternalError, to reduce logging we have removed logging from quite a few places which is acceptable but when ErrInternalError occurs we should have a facility to log the corresponding error, this helps to debug Minio server.
Showing the changes to cmd/api-errors.go (1 of 18 files). Show all
Unified · Split
| @@ -23,6 +23,7 @@ import ( · 22 unmodified lines | |||
| 23 | "net/http" | 23 | "net/http" |
| 24 | 24 | ||
| 25 | "github.com/minio/minio/cmd/crypto" | 25 | "github.com/minio/minio/cmd/crypto" |
| 26 | "github.com/minio/minio/cmd/logger" | ||
| 26 | "github.com/minio/minio/pkg/auth" | 27 | "github.com/minio/minio/pkg/auth" |
| 27 | "github.com/minio/minio/pkg/dns" | 28 | "github.com/minio/minio/pkg/dns" |
| 28 | "github.com/minio/minio/pkg/event" | 29 | "github.com/minio/minio/pkg/event" |
| @@ -1440,7 +1441,7 @@ var errorCodeResponse = map[APIErrorCode]APIError{ · 1411 unmodified lines | |||
| 1440 | // toAPIErrorCode - Converts embedded errors. Convenience | 1441 | // toAPIErrorCode - Converts embedded errors. Convenience |
| 1441 | // function written to handle all cases where we have known types of | 1442 | // function written to handle all cases where we have known types of |
| 1442 | // errors returned by underlying layers. | 1443 | // errors returned by underlying layers. |
| 1443 | func toAPIErrorCode(err error) (apiErr APIErrorCode) { | 1444 | func toAPIErrorCode(ctx context.Context, err error) (apiErr APIErrorCode) { |
| 1444 | if err == nil { | 1445 | if err == nil { |
| 1445 | return ErrNone | 1446 | return ErrNone |
| 1446 | } | 1447 | } |
| @@ -1767,6 +1768,10 @@ func toAPIErrorCode(err error) (apiErr APIErrorCode) { · 320 unmodified lines | |||
| 1767 | apiErr = ErrObjectTampered | 1768 | apiErr = ErrObjectTampered |
| 1768 | default: | 1769 | default: |
| 1769 | apiErr = ErrInternalError | 1770 | apiErr = ErrInternalError |
| 1771 | // Make sure to log the errors which we cannot translate | ||
| 1772 | // to a meaningful S3 API errors. This is added to aid in | ||
| 1773 | // debugging unexpected/unhandled errors. | ||
| 1774 | logger.LogIf(ctx, err) | ||
| 1770 | } | 1775 | } |
| 1771 | 1776 | ||
| 1772 | return apiErr | 1777 | return apiErr |