@@ -18,6 +18,7 @@ import { Difficulty } from './difficulty.model';
18
18
import { DifficultyLevels } from './difficulty-levels.enum' ;
19
19
import { QuestionService } from './question.service' ;
20
20
import { forkJoin } from 'rxjs' ;
21
+ import { HttpErrorResponse } from '@angular/common/http' ;
21
22
22
23
@Component ( {
23
24
selector : 'app-questions' ,
@@ -201,12 +202,12 @@ export class QuestionsComponent implements OnInit {
201
202
this . questions = [ ...this . questions , response . data ] ;
202
203
}
203
204
} ,
204
- error : ( error : Error ) => {
205
+ error : ( error : HttpErrorResponse ) => {
205
206
console . log ( error ) ;
206
207
this . messageService . add ( {
207
208
severity : 'error' ,
208
209
summary : 'Error' ,
209
- detail : 'Failed to add new question. Please try again later.' ,
210
+ detail : 'Failed to add new question. ' + error . error . message ,
210
211
life : 3000 ,
211
212
} ) ;
212
213
} ,
@@ -230,12 +231,12 @@ export class QuestionsComponent implements OnInit {
230
231
this . questions = this . questions ?. filter ( val => ! this . selectedQuestions ?. includes ( val ) ) ;
231
232
this . selectedQuestions = null ;
232
233
} ,
233
- error : ( ) => {
234
+ error : ( error : HttpErrorResponse ) => {
234
235
// Handle any errors from the forkJoin if necessary
235
236
this . messageService . add ( {
236
237
severity : 'error' ,
237
238
summary : 'Error' ,
238
- detail : 'Some questions could not be deleted. Please try again later.' ,
239
+ detail : 'Some questions could not be deleted. ' + error . error . message ,
239
240
life : 3000 ,
240
241
} ) ;
241
242
} ,
@@ -255,13 +256,13 @@ export class QuestionsComponent implements OnInit {
255
256
next : ( response : SingleQuestionResponse ) => {
256
257
this . questions [ this . questions . findIndex ( x => x . id == id ) ] = response . data ;
257
258
} ,
258
- error : ( error : Error ) => {
259
+ error : ( error : HttpErrorResponse ) => {
259
260
console . log ( error ) ;
260
261
console . log ( question ) ;
261
262
this . messageService . add ( {
262
263
severity : 'error' ,
263
264
summary : 'Error' ,
264
- detail : 'Failed to edit question. Please try again later.' ,
265
+ detail : error . error . message ,
265
266
life : 3000 ,
266
267
} ) ;
267
268
} ,
0 commit comments