mirror of
https://github.com/aljazceru/njump.git
synced 2025-12-17 14:24:27 +01:00
more helpful error messages.
This commit is contained in:
20
pages.go
20
pages.go
@@ -449,7 +449,7 @@ type ErrorPage struct {
|
||||
HeadCommonPartial `tmpl:"head_common"`
|
||||
TopPartial `tmpl:"top"`
|
||||
FooterPartial `tmpl:"footer"`
|
||||
Message string
|
||||
Message template.HTML
|
||||
Errors string
|
||||
}
|
||||
|
||||
@@ -457,15 +457,15 @@ func (e *ErrorPage) TemplateText() string {
|
||||
if e.Message != "" {
|
||||
return tmplError
|
||||
}
|
||||
e.Message = "I cannot give any suggestions to solve the problem, maybe the best solution is to pubblicy blame the devs on Nostr"
|
||||
if strings.Contains(e.Errors, "invalid checksum") {
|
||||
e.Message = "It seems you entered an invalid event code, try to check if it is correct; a good idea is compare the first and the last characters"
|
||||
} else if strings.Contains(e.Errors, "couldn't find this") {
|
||||
e.Message = "I can't find the event, maybe it is new and has not been already propagated on the relays I'm checking; you can try again in some time"
|
||||
} else if strings.Contains(e.Errors, "invalid bech32 string length") {
|
||||
e.Message = "I can't find what you are serching for, and this doesn't seem an event at all, sorry"
|
||||
} else if strings.Contains(e.Errors, "invalid separator") {
|
||||
e.Message = "This is so wrong I can't even begin to help you, you are probably trolling me"
|
||||
switch {
|
||||
case strings.Contains(e.Errors, "invalid checksum"):
|
||||
e.Message = "It looks like you entered an invalid event code.<br> 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"):
|
||||
e.Message = "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"):
|
||||
e.Message = "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...)"
|
||||
default:
|
||||
e.Message = "I can't give any suggestions to solve the problem.<br> Please tag <a href='/dtonon.com'>daniele</a> and <a href='/fiatjaf.com'>fiatjaf</a> and complain!"
|
||||
}
|
||||
return tmplError
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user