File tree 6 files changed +32
-15
lines changed
6 files changed +32
-15
lines changed Original file line number Diff line number Diff line change @@ -278,8 +278,8 @@ export class Modax extends RapidElement {
278
278
// this.cancelToken = CancelToken.source();
279
279
this . fetching = true ;
280
280
this . body = this . getLoading ( ) ;
281
- getUrl ( this . endpoint , null , this . getHeaders ( ) ) . then (
282
- ( response : WebResponse ) => {
281
+ getUrl ( this . endpoint , null , this . getHeaders ( ) )
282
+ . then ( ( response : WebResponse ) => {
283
283
// if it's a full page, breakout of the modal
284
284
if ( response . body . indexOf ( '<!DOCTYPE HTML>' ) == 0 ) {
285
285
this . open = false ;
@@ -294,8 +294,12 @@ export class Modax extends RapidElement {
294
294
} ) ;
295
295
} ) ;
296
296
}
297
- }
298
- ) ;
297
+ } )
298
+ . catch ( ( error ) => {
299
+ this . fetching = false ;
300
+ this . open = false ;
301
+ this . fireCustomEvent ( CustomEventType . Error , { error } ) ;
302
+ } ) ;
299
303
}
300
304
301
305
public submit ( extra = { } ) : void {
Original file line number Diff line number Diff line change @@ -279,5 +279,6 @@ export enum CustomEventType {
279
279
DragStart = 'temba-drag-start' ,
280
280
DragStop = 'temba-drag-stop' ,
281
281
Resized = 'temba-resized' ,
282
- DetailsChanged = 'temba-details-changed'
282
+ DetailsChanged = 'temba-details-changed' ,
283
+ Error = 'temba-error'
283
284
}
Original file line number Diff line number Diff line change @@ -129,6 +129,11 @@ export class ContentMenu extends RapidElement {
129
129
} ) ;
130
130
} )
131
131
. catch ( ( error : any ) => {
132
+ this . fireCustomEvent ( CustomEventType . Loaded , {
133
+ buttons : this . buttons ,
134
+ items : this . items
135
+ } ) ;
136
+
132
137
console . error ( error ) ;
133
138
} ) ;
134
139
}
Original file line number Diff line number Diff line change @@ -308,7 +308,7 @@ export class TembaList extends RapidElement {
308
308
this . items = newItems ;
309
309
}
310
310
} catch ( error ) {
311
- // console.error(error) ;
311
+ this . paused = true ;
312
312
}
313
313
}
314
314
@@ -332,7 +332,6 @@ export class TembaList extends RapidElement {
332
332
333
333
try {
334
334
const page = await fetchResultsPage ( endpoint , controller ) ;
335
-
336
335
// sanitize our options if necessary
337
336
if ( this . sanitizeOption ) {
338
337
page . results . forEach ( this . sanitizeOption ) ;
@@ -350,10 +349,10 @@ export class TembaList extends RapidElement {
350
349
} catch ( error ) {
351
350
// aborted
352
351
this . reset ( ) ;
353
- console . log ( error ) ;
352
+ this . paused = true ;
353
+ this . loading = false ;
354
354
return ;
355
355
}
356
-
357
356
this . nextPage = nextPage ;
358
357
}
359
358
this . pages = pages ;
Original file line number Diff line number Diff line change @@ -772,8 +772,8 @@ export class TembaMenu extends ResizeElement {
772
772
private loadItems ( item : MenuItem , event : MouseEvent = null ) {
773
773
if ( item && item . endpoint ) {
774
774
item . loading = true ;
775
- this . httpComplete = fetchResults ( item . endpoint ) . then (
776
- ( items : MenuItem [ ] ) => {
775
+ this . httpComplete = fetchResults ( item . endpoint )
776
+ . then ( ( items : MenuItem [ ] ) => {
777
777
items . forEach ( ( newItem ) => {
778
778
if ( ! newItem . items ) {
779
779
const prevItem = ( item . items || [ ] ) . find (
@@ -811,8 +811,10 @@ export class TembaMenu extends ResizeElement {
811
811
812
812
this . requestUpdate ( 'root' ) ;
813
813
this . scrollSelectedIntoView ( ) ;
814
- }
815
- ) ;
814
+ } )
815
+ . catch ( ( error ) => {
816
+ this . fireCustomEvent ( CustomEventType . Error , { error } ) ;
817
+ } ) ;
816
818
}
817
819
}
818
820
Original file line number Diff line number Diff line change @@ -123,6 +123,11 @@ export const getUrl = (
123
123
124
124
fetch ( url , options )
125
125
. then ( ( response ) => {
126
+ if ( response . status < 200 || response . status >= 300 ) {
127
+ reject ( response ) ;
128
+ return ;
129
+ }
130
+
126
131
response . text ( ) . then ( ( body : string ) => {
127
132
let json = { } ;
128
133
try {
@@ -177,7 +182,9 @@ export const fetchResultsPage = (
177
182
next : response . json . next
178
183
} ) ;
179
184
} )
180
- . catch ( ( error ) => reject ( error ) ) ;
185
+ . catch ( ( error ) => {
186
+ return reject ( error ) ;
187
+ } ) ;
181
188
} ) ;
182
189
} ;
183
190
@@ -326,7 +333,6 @@ export const postFormData = (
326
333
}
327
334
} )
328
335
. catch ( ( err ) => {
329
- console . error ( err ) ;
330
336
reject ( err ) ;
331
337
} ) ;
332
338
} ) ;
You can’t perform that action at this time.
0 commit comments