fix: display error page instead of panic on non existant note (#30)
All checks were successful
/ pre-commit (push) Successful in 1m7s
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:
parent
e03aa6b87a
commit
e2d3146222
1 changed files with 6 additions and 0 deletions
|
@ -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)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue