mirror of
https://github.com/makew0rld/amfora.git
synced 2024-12-04 14:46:29 -05:00
Merge pull request #73 from a-h/master
Prevent panic on empty meta with 40/50 response codes
This commit is contained in:
commit
a31e270159
@ -6,7 +6,7 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/dustin/go-humanize"
|
humanize "github.com/dustin/go-humanize"
|
||||||
"github.com/gdamore/tcell"
|
"github.com/gdamore/tcell"
|
||||||
"github.com/makeworld-the-better-one/amfora/config"
|
"github.com/makeworld-the-better-one/amfora/config"
|
||||||
"github.com/spf13/viper"
|
"github.com/spf13/viper"
|
||||||
@ -154,11 +154,14 @@ func modalInit() {
|
|||||||
|
|
||||||
// Error displays an error on the screen in a modal.
|
// Error displays an error on the screen in a modal.
|
||||||
func Error(title, text string) {
|
func Error(title, text string) {
|
||||||
// Capitalize and add period if necessary - because most errors don't do that
|
if text == "" {
|
||||||
|
text = "No additional information."
|
||||||
|
} else {
|
||||||
text = strings.ToUpper(string([]rune(text)[0])) + text[1:]
|
text = strings.ToUpper(string([]rune(text)[0])) + text[1:]
|
||||||
if !strings.HasSuffix(text, ".") && !strings.HasSuffix(text, "!") && !strings.HasSuffix(text, "?") {
|
if !strings.HasSuffix(text, ".") && !strings.HasSuffix(text, "!") && !strings.HasSuffix(text, "?") {
|
||||||
text += "."
|
text += "."
|
||||||
}
|
}
|
||||||
|
}
|
||||||
// Add spaces to title for aesthetic reasons
|
// Add spaces to title for aesthetic reasons
|
||||||
title = " " + strings.TrimSpace(title) + " "
|
title = " " + strings.TrimSpace(title) + " "
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user