ShortURL: Use new Error type (#50859)

This commit is contained in:
Emil Tullstedt
2022-06-15 15:11:36 +02:00
committed by GitHub
parent f82264c2b1
commit f1834163ec
5 changed files with 40 additions and 25 deletions
+12
View File
@@ -80,6 +80,18 @@ func (b Base) Errorf(format string, args ...interface{}) Error {
}
}
// Is validates that an Error has the same reason and messageID as the
// Base.
func (b Base) Is(err error) bool {
gfErr := Error{}
ok := errors.As(err, &gfErr)
if !ok {
return false
}
return b.reason.Status() == gfErr.Reason.Status() && b.messageID == gfErr.MessageID
}
// Error is the error type for errors within Grafana, extending
// the Go error type with Grafana specific metadata to reduce
// boilerplate error handling for status codes and internationalization