package main
import (
"strings"
"html/template"
)
type ErrorPageParams struct {
HeadParams
Errors string
Message string
// for when we can't find an event, but we still want to give the user a chance to open it elsewhere
Clients []ClientReference
}
func (e *ErrorPageParams) MessageHTML() template.HTML {
if e.Message != "" {
return template.HTML(e.Message)
}
switch {
case strings.Contains(e.Errors, "invalid checksum"):
return "It looks like you entered an invalid event code.
Check if you copied it fully, a good idea is compare the first and the last characters."
case strings.Contains(e.Errors, "couldn't find this"):
return "Can't find the event in the relays. Try getting an `nevent1` code with relay hints."
case strings.Contains(e.Errors, "invalid bech32 string length"),
strings.Contains(e.Errors, "invalid separator"),
strings.Contains(e.Errors, "not part of charset"):
return "You have typed a wrong event code, we need a URL path that starts with /npub1, /nprofile1, /nevent1, /naddr1, or something like /name@domain.com (or maybe just /domain.com) or an event id as hex (like /aef8b32af...)"
case strings.Contains(e.Errors, "profile metadata not found"):
return "We couldn't find the metadata (name, picture etc) for the specified user. Please check back here in 6 hours."
default:
return "I can't give any suggestions to solve the problem.
Please tag daniele and fiatjaf and complain!"
}
}
templ errorTemplate(params ErrorPageParams) {