mirror of
https://github.com/penpot/penpot.git
synced 2026-04-25 11:18:36 +00:00
✨ Show detailed messages on file import errors (#9004)
* ✨ Show detailed messages on file import errors Signed-off-by: jsdevninja <topit89807@gmail.com> * ✨ Fix test * ✨ Fix build error --------- Signed-off-by: jsdevninja <topit89807@gmail.com>
This commit is contained in:
parent
361c1c574b
commit
25e6b939ba
@ -295,7 +295,9 @@
|
||||
|
||||
import-error?
|
||||
[:div {:class (stl/css :error-message)}
|
||||
(tr "labels.error")]
|
||||
(if (some? (:error entry))
|
||||
(tr (:error entry))
|
||||
(tr "labels.error"))]
|
||||
|
||||
(and (not import-success?) (some? progress))
|
||||
[:div {:class (stl/css :progress-message)} (parse-progress-message progress)])
|
||||
@ -491,7 +493,12 @@
|
||||
[:ul {:class (stl/css :import-error-list)}
|
||||
(for [entry entries]
|
||||
(when (contains? #{:import-error :analyze-error} (:status entry))
|
||||
[:li {:class (stl/css :import-error-list-enry)} (:name entry)]))]
|
||||
[:li {:class (stl/css :import-error-list-enry)
|
||||
:key (dm/str (or (:file-id entry) (:uri entry) (:name entry)))}
|
||||
[:div (:name entry)]
|
||||
(when-let [err (:error entry)]
|
||||
[:div {:class (stl/css :import-error-detail)}
|
||||
(tr err)])]))]
|
||||
[:div (tr "dashboard.import.import-error.message2")]]
|
||||
|
||||
(for [entry entries]
|
||||
|
||||
17
frontend/src/app/main/ui/dashboard/import.scss
vendored
17
frontend/src/app/main/ui/dashboard/import.scss
vendored
@ -149,10 +149,16 @@
|
||||
.progress-message {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
height: deprecated.$s-32;
|
||||
min-height: deprecated.$s-32;
|
||||
color: var(--modal-text-foreground-color);
|
||||
}
|
||||
|
||||
.error-message {
|
||||
align-items: flex-start;
|
||||
white-space: pre-wrap;
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
|
||||
.linked-library {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
@ -258,3 +264,12 @@
|
||||
.import-error-list-enry {
|
||||
padding: var(--sp-xs) 0;
|
||||
}
|
||||
|
||||
.import-error-detail {
|
||||
@include deprecated.body-small-typography;
|
||||
|
||||
margin-top: var(--sp-xs);
|
||||
color: var(--modal-text-foreground-color);
|
||||
white-space: pre-wrap;
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
|
||||
@ -23,6 +23,22 @@
|
||||
|
||||
(log/set-level! :warn)
|
||||
|
||||
(defn- import-cause-message
|
||||
"Prefer the server `:hint` (full text, e.g. SSE error payload), then `:explain`
|
||||
when present; avoid the generic `stream exception` wrapper when a payload exists."
|
||||
[cause default-msg]
|
||||
(let [data (ex-data cause)
|
||||
hint (some-> data :hint str/trim)
|
||||
explain (some-> data :explain str/trim)]
|
||||
(cond
|
||||
(not (str/blank? hint)) hint
|
||||
(not (str/blank? explain)) explain
|
||||
:else
|
||||
(let [msg (some-> (ex-message cause) str/trim)]
|
||||
(if (or (str/blank? msg) (= msg "stream exception"))
|
||||
default-msg
|
||||
msg)))))
|
||||
|
||||
;; Upload changes batches size
|
||||
(def ^:const change-batch-size 100)
|
||||
|
||||
@ -122,7 +138,7 @@
|
||||
:error (tr "dashboard.import.analyze-error")}))))
|
||||
|
||||
(rx/catch (fn [cause]
|
||||
(let [error (or (ex-message cause) (tr "dashboard.import.analyze-error"))]
|
||||
(let [error (import-cause-message cause (tr "dashboard.import.analyze-error"))]
|
||||
(rx/of (assoc file :error error :status :error))))))))
|
||||
|
||||
(defmethod impl/handler :analyze-import
|
||||
@ -178,7 +194,7 @@
|
||||
:project-id project-id
|
||||
:cause cause)
|
||||
(rx/of {:status :error
|
||||
:error (ex-message cause)
|
||||
:error (import-cause-message cause (tr "labels.error"))
|
||||
:file-id (:file-id data)})))))))
|
||||
|
||||
(->> (rx/from binfile-v3)
|
||||
@ -212,8 +228,9 @@
|
||||
:project-id project-id
|
||||
::log/sync? true
|
||||
:cause cause)
|
||||
(->> (rx/from entries)
|
||||
(rx/map (fn [entry]
|
||||
{:status :error
|
||||
:error (ex-message cause)
|
||||
:file-id (:file-id entry)}))))))))))))
|
||||
(let [err (import-cause-message cause (tr "labels.error"))]
|
||||
(->> (rx/from entries)
|
||||
(rx/map (fn [entry]
|
||||
{:status :error
|
||||
:error err
|
||||
:file-id (:file-id entry)})))))))))))))
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user