Simplify error handling for JsonRestHandler (#13369)

* Simplify error handling for `JsonRestHandler`

* POST

* reduce complexity

* review feedback

* uncomment route

* fix rest of tests
This commit is contained in:
Radosław Kapka
2023-12-22 23:39:20 +01:00
committed by GitHub
parent b7e0819f00
commit d0bf03e863
56 changed files with 254 additions and 525 deletions

View File

@@ -137,7 +137,8 @@ func StringContains(loggerFn assertionLoggerFn, expected, actual string, flag bo
// NoError asserts that error is nil.
func NoError(loggerFn assertionLoggerFn, err error, msg ...interface{}) {
if err != nil {
// reflect.ValueOf is needed for nil instances of custom types implementing Error
if err != nil && !reflect.ValueOf(err).IsNil() {
errMsg := parseMsg("Unexpected error", msg...)
_, file, line, _ := runtime.Caller(2)
loggerFn("%s:%d %s: %v", filepath.Base(file), line, errMsg, err)