fix: display error page instead of panic on non existant note (#30)
All checks were successful
/ pre-commit (push) Successful in 1m7s

Same that #24 but for non password protected notes

Co-authored-by: Thibault Piron <thibault.a.piron@gmail.com>
Reviewed-on: #30
Reviewed-by: Julien Riou <jriou@monitoring@riou.xyz>
Co-authored-by: tapiron <tapiron@monitoring@riou.xyz>
Co-committed-by: tapiron <tapiron@monitoring@riou.xyz>
This commit is contained in:
tapiron 2025-09-15 18:30:03 +02:00 committed by Julien Riou
commit e2d3146222

View file

@ -341,6 +341,12 @@ func (h *GetWebNoteHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
return return
} }
if note == nil {
h.PageData.Err = fmt.Errorf("Note doesn't exist or has been deleted")
h.Templates.ExecuteTemplate(w, templateName, h.PageData)
return
}
if note.Encrypted { if note.Encrypted {
h.PageData.Err = fmt.Errorf("note is encrypted") h.PageData.Err = fmt.Errorf("note is encrypted")
h.Templates.ExecuteTemplate(w, templateName, h.PageData) h.Templates.ExecuteTemplate(w, templateName, h.PageData)