graph/education: slightly improve error handling and logging

- Use var for common errors
- Add the addition error message to the Error() output of errorcode.Error
- in PatchEducationSchool() use errorcode.RenderError() to turn the errorcode
  in to the right HTTP Status (instead of return 500 always)
This commit is contained in:
Ralf Haferkamp
2023-09-27 15:39:00 +02:00
committed by Ralf Haferkamp
parent 4f59de9c52
commit a34d467285
8 changed files with 42 additions and 69 deletions
@@ -130,7 +130,11 @@ func (e ErrorCode) String() string {
}
func (e Error) Error() string {
return errorCodes[e.errorCode]
errString := errorCodes[e.errorCode]
if e.msg != "" {
errString += ": " + e.msg
}
return errString
}
// RenderError render the Graph Error based on a code or default one