Don't capitalize error strings (staticcheck).

This commit is contained in:
Martin Dosch 2022-05-03 14:20:32 +02:00
parent 2f2a2fd4fd
commit 52adb579d8

26
ox.go
View File

@ -58,26 +58,26 @@ func oxDecrypt(m xmpp.Chat, client *xmpp.Client, iqc chan xmpp.IQ,
}
signcrypt := doc.SelectElement("signcrypt")
if signcrypt == nil {
return "error", time.Now(), errors.New("Ox: no signcrypt element")
return "error", time.Now(), errors.New("ox: no signcrypt element")
}
to := signcrypt.SelectElement("to")
if to == nil {
return "error", time.Now(), errors.New("Ox: no to element")
return "error", time.Now(), errors.New("ox: no to element")
}
jid := to.SelectAttr("jid")
if jid == nil {
return "error", time.Now(), errors.New("Ox: no jid attribute")
return "error", time.Now(), errors.New("ox: no jid attribute")
}
if strings.Split(jid.Value, "/")[0] != user {
return "error", time.Now(), errors.New("Ox: encrypted for wrong user")
return "error", time.Now(), errors.New("ox: encrypted for wrong user")
}
timestamp := signcrypt.SelectElement("time")
if timestamp == nil {
return "error", time.Now(), errors.New("Ox: no time element")
return "error", time.Now(), errors.New("ox: no time element")
}
stamp := timestamp.SelectAttr("stamp")
if stamp == nil {
return "error", time.Now(), errors.New("Ox: no stamp attribute")
return "error", time.Now(), errors.New("ox: no stamp attribute")
}
msgStamp, err := time.Parse("2006-01-02T15:04:05Z0700", stamp.Value)
if err != nil {
@ -85,7 +85,7 @@ func oxDecrypt(m xmpp.Chat, client *xmpp.Client, iqc chan xmpp.IQ,
}
payload := signcrypt.SelectElement("payload")
if payload == nil {
return "error", time.Now(), errors.New("Ox: no payload element")
return "error", time.Now(), errors.New("ox: no payload element")
}
body := payload.SelectElement("body")
if body == nil {
@ -205,19 +205,19 @@ func oxPublishPubKey(jid string, client *xmpp.Client, iqc chan xmpp.IQ,
return err
}
if iqReply.Type != "result" {
return errors.New("Error while publishing public key")
return errors.New("error while publishing public key")
}
ownPubKeyRingFromPubsub, err := oxRecvPublicKeys(client, iqc, jid, fingerprint)
if err != nil {
return errors.New("Couldn't successfully verify public key upload")
return errors.New("couldn't successfully verify public key upload")
}
ownPubKeyFromPubsub := ownPubKeyRingFromPubsub.GetKeys()[0]
ownPubKeyFromPubsubSerialized, err := ownPubKeyFromPubsub.Serialize()
if err != nil {
return errors.New("Couldn't successfully verify public key upload")
return errors.New("couldn't successfully verify public key upload")
}
if pubKeyBase64 != base64.StdEncoding.EncodeToString(ownPubKeyFromPubsubSerialized) {
return errors.New("Couldn't successfully verify public key upload")
return errors.New("couldn't successfully verify public key upload")
}
root = etree.NewDocument()
pubsub = root.CreateElement("pubsub")
@ -252,7 +252,7 @@ func oxPublishPubKey(jid string, client *xmpp.Client, iqc chan xmpp.IQ,
return err
}
if iqReply.Type != "result" {
return errors.New("Couldn't publish public key list")
return errors.New("couldn't publish public key list")
}
return nil
}
@ -550,7 +550,7 @@ func oxGetPublicKeyRing(client *xmpp.Client, iqc chan xmpp.IQ,
if !savedKeysDate.Before(newestKey) {
pubKeys := pubKeyReadXML.SelectElements("pubkey")
if pubKeys == nil {
return nil, errors.New("Couldn't read public keys from cache")
return nil, errors.New("couldn't read public keys from cache")
}
for _, r := range pubKeys {
keyByte, err := base64.StdEncoding.DecodeString(r.Text())