From 7ed8ff99827c66ebb5009a129e2d3aba34abb490 Mon Sep 17 00:00:00 2001 From: ycc Date: Thu, 1 Dec 2022 22:47:17 +0100 Subject: [PATCH] error mgt in qr write --- .gitignore | 1 + client/identity.go | 1 - contactcard.go | 7 +++---- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/.gitignore b/.gitignore index 903265f..a0c643e 100644 --- a/.gitignore +++ b/.gitignore @@ -11,3 +11,4 @@ test id.enc invitation.png client/test.cfg +.VSCodeCouter/ diff --git a/client/identity.go b/client/identity.go index 4c04dc9..a56ec87 100644 --- a/client/identity.go +++ b/client/identity.go @@ -84,7 +84,6 @@ func (id *Identity) AnswerInvitation(MyName string, ContactName string, MessageS peer.Name = ReceivedContact.Name } peer.Contact = *ReceivedContact - for _, i := range MessageServerIdxs { srv := id.MessageServers.Servers[i].ServerData myContactCard.PullServers = append(myContactCard.PullServers, &srv) diff --git a/contactcard.go b/contactcard.go index 7615a9b..92e3cf5 100644 --- a/contactcard.go +++ b/contactcard.go @@ -53,7 +53,6 @@ func (contact *ContactCard) Compress() ([]byte, error) { if err := gz.Close(); err != nil { return nil, err } - fmt.Println(b.Bytes()) return b.Bytes(), nil } @@ -143,13 +142,13 @@ func (contact *ContactCard) WritePng(filename string) { } -func (Contact *ContactCard) WriteQr(filename string) { +func (Contact *ContactCard) WriteQr(filename string) error { //jsonContact, _ := json.Marshal(Contact) jsonContact, _ := Contact.Compress() qwriter := qrcode.NewQRCodeWriter() code, err := qwriter.Encode(string(jsonContact), gozxing.BarcodeFormat_QR_CODE, 512, 512, nil) if err != nil { - println(err.Error()) + return err } file, _ := os.Create(filename) defer file.Close() @@ -157,7 +156,7 @@ func (Contact *ContactCard) WriteQr(filename string) { // *BitMatrix implements the image.Image interface, // so it is able to be passed to png.Encode directly. _ = png.Encode(file, code) - + return nil } func ReadQr(Filename string) ContactCard {