aboutsummaryrefslogtreecommitdiff
path: root/internal
diff options
context:
space:
mode:
Diffstat (limited to 'internal')
-rw-r--r--internal/server/server.go49
-rw-r--r--internal/server/templates/index.html4
2 files changed, 50 insertions, 3 deletions
diff --git a/internal/server/server.go b/internal/server/server.go
index 50ff1ea..c033059 100644
--- a/internal/server/server.go
+++ b/internal/server/server.go
@@ -12,6 +12,7 @@ import (
"net/http"
"sort"
"strconv"
+ "strings"
"time"
"github.com/Fuwn/kaze/internal/config"
@@ -556,6 +557,54 @@ func templateFuncs() template.FuncMap {
}
return "bg-neutral-200 dark:bg-neutral-800"
},
+ "simplifyError": func(err string) string {
+ if err == "" {
+ return ""
+ }
+ // Common error patterns to simplify
+ switch {
+ case strings.Contains(err, "no such host"):
+ return "DNS lookup failed"
+ case strings.Contains(err, "connection refused"):
+ return "Connection refused"
+ case strings.Contains(err, "connection reset"):
+ return "Connection reset"
+ case strings.Contains(err, "timeout"):
+ return "Timeout"
+ case strings.Contains(err, "certificate"):
+ return "SSL/TLS error"
+ case strings.Contains(err, "EOF"):
+ return "Connection closed"
+ case strings.Contains(err, "status code"):
+ // Extract status code if present
+ if idx := strings.Index(err, "status code"); idx != -1 {
+ rest := err[idx:]
+ // Try to find the number
+ for i, c := range rest {
+ if c >= '0' && c <= '9' {
+ end := i
+ for end < len(rest) && rest[end] >= '0' && rest[end] <= '9' {
+ end++
+ }
+ return "HTTP " + rest[i:end]
+ }
+ }
+ }
+ return "Unexpected status"
+ case strings.Contains(err, "expected content"):
+ return "Content mismatch"
+ case strings.Contains(err, "i/o timeout"):
+ return "I/O timeout"
+ case strings.Contains(err, "network is unreachable"):
+ return "Network unreachable"
+ default:
+ // Truncate long errors
+ if len(err) > 30 {
+ return err[:27] + "..."
+ }
+ return err
+ }
+ },
"tickTooltipData": func(tick *storage.TickData, mode, timezone string, hidePing bool) string {
if tick == nil {
data := map[string]interface{}{"header": "No data"}
diff --git a/internal/server/templates/index.html b/internal/server/templates/index.html
index 6b28edb..eb3fc41 100644
--- a/internal/server/templates/index.html
+++ b/internal/server/templates/index.html
@@ -99,9 +99,7 @@
{{if gt .SSLDaysLeft 0}}
<span class="{{if lt .SSLDaysLeft 14}}text-yellow-600 dark:text-yellow-400{{else if lt .SSLDaysLeft 7}}text-red-600 dark:text-red-400{{end}}" data-tooltip='{{.SSLTooltip}}'>SSL: {{.SSLDaysLeft}}d</span>
{{end}}
- {{if .LastError}}
- {{if .LastError}}<span class="text-red-600 dark:text-red-400 truncate max-w-[200px]" data-tooltip='{"header":"Last Error","error":"{{.LastError}}"}'>{{.LastError}}</span>{{end}}
- {{end}}
+ {{if .LastError}}<span class="text-red-600 dark:text-red-400 truncate max-w-[200px]" data-tooltip='{"header":"Last Error","error":"{{.LastError}}"}'>{{simplifyError .LastError}}</span>{{end}}
</div>
</div>
<div class="flex items-center gap-2 flex-shrink-0">