0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-01-25 07:58:49 -05:00

🐛 Show proper 404 when look on not-existing page on viewer.

This commit is contained in:
Andrey Antukh 2021-10-06 14:14:40 +02:00 committed by Andrés Moya
parent 9ecbddc18c
commit f3bb5c55f5
2 changed files with 19 additions and 13 deletions

View file

@ -142,17 +142,23 @@
(when expl (js/console.error expl))
(js/console.groupEnd msg)))
(defn on-unhandled-error
[error]
(if (instance? ExceptionInfo error)
(-> error sentry/capture-exception ex-data ptk/handle-error)
(let [hint (ex-message error)
msg (str "Unhandled Internal Error: " hint)]
(sentry/capture-exception error)
(ts/schedule (st/emitf (rt/assign-exception error)))
(js/console.group msg)
(ex/ignoring (js/console.error error))
(js/console.groupEnd msg))))
(defonce uncaught-error-handler
(letfn [(on-error [event]
(.preventDefault ^js event)
(when-let [error (unchecked-get event "error")]
(let [hint (ex-message error)
msg (str "Unhandled Internal Error: " hint)]
(sentry/capture-exception error)
(ts/schedule (st/emitf (rt/assign-exception error)))
(js/console.group msg)
(ex/ignoring (js/console.error error))
(js/console.groupEnd msg))))]
(some-> (unchecked-get event "error")
(on-unhandled-error)))]
(.addEventListener js/window "error" on-error)
(fn []
(.removeEventListener js/window "error" on-error))))

View file

@ -6,6 +6,7 @@
(ns app.main.ui.viewer
(:require
[app.common.exceptions :as ex]
[app.common.geom.point :as gpt]
[app.main.data.comments :as dcm]
[app.main.data.viewer :as dv]
@ -38,14 +39,10 @@
[{:keys [params data]}]
(let [{:keys [page-id section index]} params
{:keys [file users project perms]} data
local (mf/deref refs/viewer-local)
file (:file data)
users (:users data)
project (:project data)
perms (:permissions data)
page-id (or page-id (-> file :data :pages first))
page (mf/use-memo
@ -78,6 +75,9 @@
(hooks/use-shortcuts ::viewer sc/shortcuts)
(when (nil? page)
(ex/raise :type :not-found))
;; Set the page title
(mf/use-effect
(mf/deps (:name file))