mirror of
https://mau.dev/mautrix/go.git
synced 2026-03-14 14:25:53 +01:00
Use appropriate name for error variables
This was caught by go-staticcheck and marked as ST1012.
This commit is contained in:
parent
db165c9885
commit
032310a37d
2 changed files with 6 additions and 6 deletions
|
|
@ -192,7 +192,7 @@ func (as *AppService) handleEvents(evts []*event.Event, defaultTypeClass event.T
|
|||
evt.Type.Class = event.MessageEventType
|
||||
}
|
||||
err := evt.Content.ParseRaw(evt.Type)
|
||||
if errors.Is(err, event.UnsupportedContentType) {
|
||||
if errors.Is(err, event.ErrUnsupportedContentType) {
|
||||
as.Log.Debugfln("Not parsing content of %s: %v", evt.ID, err)
|
||||
} else if err != nil {
|
||||
as.Log.Debugfln("Failed to parse content of %s (type %s): %v", evt.ID, evt.Type.Type, err)
|
||||
|
|
|
|||
|
|
@ -150,19 +150,19 @@ func (content *Content) MarshalJSON() ([]byte, error) {
|
|||
}
|
||||
|
||||
func IsUnsupportedContentType(err error) bool {
|
||||
return errors.Is(err, UnsupportedContentType)
|
||||
return errors.Is(err, ErrUnsupportedContentType)
|
||||
}
|
||||
|
||||
var ContentAlreadyParsed = errors.New("content is already parsed")
|
||||
var UnsupportedContentType = errors.New("unsupported event type")
|
||||
var ErrContentAlreadyParsed = errors.New("content is already parsed")
|
||||
var ErrUnsupportedContentType = errors.New("unsupported event type")
|
||||
|
||||
func (content *Content) ParseRaw(evtType Type) error {
|
||||
if content.Parsed != nil {
|
||||
return ContentAlreadyParsed
|
||||
return ErrContentAlreadyParsed
|
||||
}
|
||||
structType, ok := TypeMap[evtType]
|
||||
if !ok {
|
||||
return fmt.Errorf("%w %s", UnsupportedContentType, evtType.Repr())
|
||||
return fmt.Errorf("%w %s", ErrUnsupportedContentType, evtType.Repr())
|
||||
}
|
||||
content.Parsed = reflect.New(structType).Interface()
|
||||
return json.Unmarshal(content.VeryRaw, &content.Parsed)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue