Bläddra i källkod

ui: capture invalid pdf error

Junyi Du 3 år sedan
förälder
incheckning
6746c8813e
2 ändrade filer med 16 tillägg och 3 borttagningar
  1. 13 3
      src/main/frontend/extensions/pdf/highlights.cljs
  2. 3 0
      src/main/frontend/ui.cljs

+ 13 - 3
src/main/frontend/extensions/pdf/highlights.cljs

@@ -1078,9 +1078,19 @@
             "MissingPDFException"
             (do
               (notification/show!
-                (str (.-message error) " Is this the correct path?")
-                :error
-                false)
+               (str (.-message error) " Is this the correct path?")
+               :error
+               false)
+              (state/set-state! :pdf/current nil))
+
+            "InvalidPDFException"
+            (do
+              (notification/show!
+               (str (.-message error) "\n"
+                    "Is this .pdf file corrupted?\n"
+                    "Please confirm with external pdf viewer.")
+               :error
+               false)
               (state/set-state! :pdf/current nil)))))
       [(:error state)])
 

+ 3 - 0
src/main/frontend/ui.cljs

@@ -715,6 +715,9 @@
   < {:did-catch
      (fn [state error _info]
        (log/error :exception error)
+       (notification-handler/show!
+        (str "Error caught by UI!\n " error)
+        :error)
        (assoc state ::error error))}
   [{error ::error, c :rum/react-component} error-view view]
   (if (some? error)