File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -18,6 +18,7 @@ import {
1818 versionContext ,
1919} from './context' ;
2020import type { ToastManager } from './lit-toast' ;
21+ import type { ProblemDetail } from './types' ;
2122import {
2223 type CaptchaRequiredResponse ,
2324 getCaptchaCodeHeader ,
@@ -156,8 +157,14 @@ export class CommentForm extends LitElement {
156157 this . toastManager ?. warn ( detail ) ;
157158 return ;
158159 }
159- }
160160
161+ const problemDetail = error . data as unknown as ProblemDetail ;
162+ this . toastManager ?. error (
163+ [ problemDetail ?. title , problemDetail ?. detail ] . join ( ' - ' ) ||
164+ msg ( 'Comment failed, please try again later' )
165+ ) ;
166+ return ;
167+ }
161168 this . toastManager ?. error ( msg ( 'Comment failed, please try again later' ) ) ;
162169 } finally {
163170 this . submitting = false ;
Original file line number Diff line number Diff line change @@ -20,6 +20,7 @@ import {
2020 toastContext ,
2121} from './context' ;
2222import type { ToastManager } from './lit-toast' ;
23+ import type { ProblemDetail } from './types' ;
2324import {
2425 type CaptchaRequiredResponse ,
2526 getCaptchaCodeHeader ,
@@ -160,6 +161,13 @@ export class ReplyForm extends LitElement {
160161 this . toastManager ?. warn ( detail ) ;
161162 return ;
162163 }
164+
165+ const problemDetail = error . data as unknown as ProblemDetail ;
166+ this . toastManager ?. error (
167+ [ problemDetail ?. title , problemDetail ?. detail ] . join ( ' - ' ) ||
168+ msg ( 'Comment failed, please try again later' )
169+ ) ;
170+ return ;
163171 }
164172
165173 this . toastManager ?. error ( msg ( 'Comment failed, please try again later' ) ) ;
Original file line number Diff line number Diff line change @@ -32,3 +32,13 @@ interface AvatarConfig {
3232interface EditorConfig {
3333 placeholder ?: string ;
3434}
35+
36+ export interface ProblemDetail {
37+ type : string ;
38+ title : string ;
39+ status : number ;
40+ detail : string ;
41+ instance : string ;
42+ requestId : string ;
43+ timestamp : string ;
44+ }
You can’t perform that action at this time.
0 commit comments