Skip to content

Commit d0774ba

Browse files
committed
refactor: use ErrorDisplay from UI struct
1 parent 33ed861 commit d0774ba

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+111
-94
lines changed

internal/app/app.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,8 @@ func isToday(t time.Time) bool {
7474
return t.Day() == n.Day() && t.Month() == n.Month() && t.Year() == n.Year()
7575
}
7676

77+
// FIXME: Migrate to UI variant, which recognizes developer state.
78+
7779
// ErrorDisplay returns a user friendly error message for an error.
7880
func ErrorDisplay(err error) string {
7981
if err == nil {

internal/app/assetui/assetbrowser.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ func (a *AssetBrowser) Update(ctx context.Context) {
128128
}
129129
reportError := func(err error) {
130130
slog.Error("Failed to update asset browser", "error", err)
131-
setFooter(app.ErrorDisplay(err), widget.DangerImportance)
131+
setFooter(a.u.ErrorDisplay(err), widget.DangerImportance)
132132
}
133133
el, err := a.u.EVEUniverse().ListLocations(ctx)
134134
if err != nil {

internal/app/assetui/assetsearch.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -700,7 +700,7 @@ func (a *AssetSearch) Update(ctx context.Context) {
700700
if err != nil {
701701
slog.Error("Failed to refresh asset data", "err", err)
702702
clear()
703-
setTop("ERROR: "+app.ErrorDisplay(err), widget.DangerImportance)
703+
setTop("ERROR: "+a.u.ErrorDisplay(err), widget.DangerImportance)
704704
return
705705
}
706706
fyne.Do(func() {

internal/app/characterui/charactersheet.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ func (a *CharacterSheet) update(ctx context.Context) {
169169
c2, err := a.u.Character().GetCharacter(ctx, c.ID)
170170
if err != nil {
171171
slog.Error("Failed to fetch character for sheet", "err", err)
172-
setName("ERROR: " + app.ErrorDisplay(err))
172+
setName("ERROR: " + a.u.ErrorDisplay(err))
173173
return
174174
} else {
175175
a.character.Store(c2)

internal/app/characterui/communications.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ func (a *Communications) setDetail(n *app.CharacterNotification) {
203203
if err != nil {
204204
slog.Warn("Failed to set notification detail", "err", err)
205205
fyne.Do(func() {
206-
a.Detail.setError(app.ErrorDisplay(err))
206+
a.Detail.setError(a.u.ErrorDisplay(err))
207207
})
208208
return
209209
}
@@ -222,6 +222,7 @@ func (a *Communications) makeToolbar() *widget.Toolbar {
222222
xdialog.ShowErrorAndLog(
223223
"Failed to generated notification for clipboard",
224224
err,
225+
a.u.IsDeveloperMode(),
225226
a.u.MainWindow(),
226227
)
227228
}

internal/app/characterui/contacts.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -404,7 +404,7 @@ func (a *Contacts) update(ctx context.Context) {
404404
rows, err := a.fetchRows(ctx, characterID)
405405
if err != nil {
406406
clear()
407-
setFooter("ERROR: "+app.ErrorDisplay(err), widget.DangerImportance)
407+
setFooter("ERROR: "+a.u.ErrorDisplay(err), widget.DangerImportance)
408408
return
409409
}
410410
fyne.Do(func() {

internal/app/characterui/contracts.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -438,7 +438,7 @@ func (a *Contracts) Update(ctx context.Context) {
438438
if err != nil {
439439
slog.Error("Failed to refresh contracts UI", "err", err)
440440
fyne.Do(func() {
441-
a.footer.Text = fmt.Sprintf("ERROR: %s", app.ErrorDisplay(err))
441+
a.footer.Text = fmt.Sprintf("ERROR: %s", a.u.ErrorDisplay(err))
442442
a.footer.Importance = widget.DangerImportance
443443
a.footer.Refresh()
444444
})
@@ -569,7 +569,7 @@ func ShowCharacterContractWindow(u uiservices.UIServices, characterID, contractI
569569
ctx := context.Background()
570570
o, err := u.Character().GetContract(ctx, characterID, contractID)
571571
if err != nil {
572-
xdialog.ShowErrorAndLog("Failed to show contract", err, u.MainWindow())
572+
xdialog.ShowErrorAndLog("Failed to show contract", err, u.IsDeveloperMode(), u.MainWindow())
573573
return
574574
}
575575
title := fmt.Sprintf("Contract #%d", contractID)
@@ -654,7 +654,7 @@ func ShowCharacterContractWindow(u uiservices.UIServices, characterID, contractI
654654
case app.ContractTypeAuction:
655655
total, err := u.Character().CountContractBids(ctx, o.ID)
656656
if err != nil {
657-
xdialog.ShowErrorAndLog("Failed to show contract bids", err, u.MainWindow())
657+
xdialog.ShowErrorAndLog("Failed to show contract bids", err, u.IsDeveloperMode(), u.MainWindow())
658658
return
659659
}
660660
var currentBid string
@@ -663,7 +663,7 @@ func ShowCharacterContractWindow(u uiservices.UIServices, characterID, contractI
663663
} else {
664664
top, err := u.Character().GetContractTopBid(ctx, o.ID)
665665
if err != nil {
666-
xdialog.ShowErrorAndLog("Failed to show contract top bid", err, u.MainWindow())
666+
xdialog.ShowErrorAndLog("Failed to show contract top bid", err, u.IsDeveloperMode(), u.MainWindow())
667667
return
668668
}
669669
currentBid = fmt.Sprintf("%s (%d bids so far)", formatISKAmount(float64(top.Amount)), total)
@@ -730,7 +730,7 @@ func ShowCharacterContractWindow(u uiservices.UIServices, characterID, contractI
730730
main.Add(widget.NewSeparator())
731731
x, err := makeItemsInfo(o)
732732
if err != nil {
733-
xdialog.ShowErrorAndLog("Failed to show contract items", err, u.MainWindow())
733+
xdialog.ShowErrorAndLog("Failed to show contract items", err, u.IsDeveloperMode(), u.MainWindow())
734734
return
735735
}
736736
main.Add(x)
@@ -750,7 +750,7 @@ func ShowCorporationContractWindow(u uiservices.UIServices, corporationID, contr
750750
ctx := context.Background()
751751
o, err := u.Corporation().GetContract(ctx, corporationID, contractID)
752752
if err != nil {
753-
xdialog.ShowErrorAndLog("Failed to show contract", err, u.MainWindow())
753+
xdialog.ShowErrorAndLog("Failed to show contract", err, u.IsDeveloperMode(), u.MainWindow())
754754
return
755755
}
756756
title := fmt.Sprintf("Contract #%d", contractID)
@@ -835,7 +835,7 @@ func ShowCorporationContractWindow(u uiservices.UIServices, corporationID, contr
835835
case app.ContractTypeAuction:
836836
total, err := u.Character().CountContractBids(ctx, o.ID)
837837
if err != nil {
838-
xdialog.ShowErrorAndLog("Failed to show contract bids", err, u.MainWindow())
838+
xdialog.ShowErrorAndLog("Failed to show contract bids", err, u.IsDeveloperMode(), u.MainWindow())
839839
return
840840
}
841841
var currentBid string
@@ -844,7 +844,7 @@ func ShowCorporationContractWindow(u uiservices.UIServices, corporationID, contr
844844
} else {
845845
top, err := u.Character().GetContractTopBid(ctx, o.ID)
846846
if err != nil {
847-
xdialog.ShowErrorAndLog("Failed to show contract top bid", err, u.MainWindow())
847+
xdialog.ShowErrorAndLog("Failed to show contract top bid", err, u.IsDeveloperMode(), u.MainWindow())
848848
return
849849
}
850850
currentBid = fmt.Sprintf("%s (%d bids so far)", formatISKAmount(float64(top.Amount)), total)
@@ -911,7 +911,7 @@ func ShowCorporationContractWindow(u uiservices.UIServices, corporationID, contr
911911
main.Add(widget.NewSeparator())
912912
x, err := makeItemsInfo(o)
913913
if err != nil {
914-
xdialog.ShowErrorAndLog("Failed to show contract items", err, u.MainWindow())
914+
xdialog.ShowErrorAndLog("Failed to show contract items", err, u.IsDeveloperMode(), u.MainWindow())
915915
return
916916
}
917917
main.Add(x)

internal/app/characterui/mails.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ func (a *Mails) update(ctx context.Context) {
276276
td, folderAll, err := a.fetchFolders(ctx, characterID)
277277
if err != nil {
278278
slog.Error("Failed to build mail tree", "character", characterID, "error", err)
279-
setStatus("Error: "+app.ErrorDisplay(err), widget.DangerImportance)
279+
setStatus("Error: "+a.u.ErrorDisplay(err), widget.DangerImportance)
280280
return
281281
}
282282
unread, err := a.updateCountsInTree(ctx, characterID, td)
@@ -629,7 +629,7 @@ func (a *Mails) headerUpdate(ctx context.Context) {
629629
headers, err := a.fetchHeaders(ctx, folder)
630630
if err != nil {
631631
slog.Error("Failed to refresh mail headers UI", "characterID", folder.CharacterID, "folder", folder.Name, "err", err)
632-
setStatus("Failed to load: "+app.ErrorDisplay(err), widget.DangerImportance)
632+
setStatus("Failed to load: "+a.u.ErrorDisplay(err), widget.DangerImportance)
633633
clear()
634634
return
635635
}
@@ -705,7 +705,7 @@ func (a *Mails) MakeDeleteAction(onSuccess func()) (fyne.Resource, func()) {
705705
slog.Int64("mailID", a.mail.MailID),
706706
slog.Any("err", err),
707707
)
708-
a.u.ShowSnackbar(fmt.Sprintf("Failed to delete mail: %s", app.ErrorDisplay(err)))
708+
a.u.ShowSnackbar(fmt.Sprintf("Failed to delete mail: %s", a.u.ErrorDisplay(err)))
709709
}
710710
m.Start()
711711
}, a.u.MainWindow(),
@@ -759,7 +759,7 @@ func (a *Mails) loadMail(ctx context.Context, mailID int64) {
759759
if err != nil {
760760
slog.Error("Failed to fetch mail", "mailID", mailID, "error", err)
761761
fyne.Do(func() {
762-
a.Detail.SetBody("ERROR: Failed to load: " + app.ErrorDisplay(err))
762+
a.Detail.SetBody("ERROR: Failed to load: " + a.u.ErrorDisplay(err))
763763
})
764764
return
765765
}
@@ -784,7 +784,7 @@ func (a *Mails) loadMail(ctx context.Context, mailID int64) {
784784
if a.mail.CharacterID != characterID || a.mail.MailID != mailID {
785785
return
786786
}
787-
a.Detail.SetBody("ERROR: Failed to load: " + app.ErrorDisplay(err))
787+
a.Detail.SetBody("ERROR: Failed to load: " + a.u.ErrorDisplay(err))
788788
})
789789
return nil, nil
790790
}

internal/app/characterui/overview.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,7 @@ func (a *Overview) makeGrid() *widget.GridWrap {
305305
err := a.u.LoadCharacter(r.characterID)
306306
if err != nil {
307307
slog.Error("Failed to load character", "characterID", r.characterID, "error", err)
308-
a.u.ShowSnackbar(fmt.Sprintf("Failed to load character: %s", app.ErrorDisplay(err)))
308+
a.u.ShowSnackbar(fmt.Sprintf("Failed to load character: %s", a.u.ErrorDisplay(err)))
309309
return
310310
}
311311
}()
@@ -352,7 +352,7 @@ func (a *Overview) makeList() *widget.List {
352352
err := a.u.LoadCharacter(r.characterID)
353353
if err != nil {
354354
slog.Error("Failed to load character", "characterID", r.characterID, "error", err)
355-
a.u.ShowSnackbar(fmt.Sprintf("Failed to load character: %s", app.ErrorDisplay(err)))
355+
a.u.ShowSnackbar(fmt.Sprintf("Failed to load character: %s", a.u.ErrorDisplay(err)))
356356
return
357357
}
358358
}()
@@ -455,7 +455,7 @@ func (a *Overview) Update(ctx context.Context) {
455455
rows, err := a.fetchRows(ctx)
456456
if err != nil {
457457
clear()
458-
setFooter("ERROR: "+app.ErrorDisplay(err), widget.DangerImportance)
458+
setFooter("ERROR: "+a.u.ErrorDisplay(err), widget.DangerImportance)
459459
slog.Error("Failed to refresh overview UI", "err", err)
460460
return
461461
}

internal/app/characterui/sendmail.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ func showAddDialog(u uiservices.UIServices, characterID int64, onSelected func(e
193193
}
194194
showErrorDialog := func(search string, err error) {
195195
slog.Error("Failed to resolve names", "search", search, "error", err)
196-
xdialog.ShowErrorAndLog("Something went wrong", err, w)
196+
xdialog.ShowErrorAndLog("Something went wrong", err, u.IsDeveloperMode(), w)
197197
}
198198
entry := widget.NewEntry()
199199
entry.PlaceHolder = "Type to start searching..."

0 commit comments

Comments
 (0)