@@ -134,7 +134,7 @@ const SendInnProvider = ({
134
134
return ;
135
135
}
136
136
logger ?. error ( `${ innsendingsIdFromParams } : Failed to retrieve mellomlagring` , error as Error ) ;
137
- dispatchFyllutMellomlagring ( { type : 'error' , error : 'GET FAILED ' } ) ;
137
+ dispatchFyllutMellomlagring ( { type : 'error' , error : 'GET_FAILED ' } ) ;
138
138
setInitStatus ( 'error' ) ;
139
139
}
140
140
} ;
@@ -199,7 +199,7 @@ const SendInnProvider = ({
199
199
}
200
200
return response ;
201
201
} catch ( error : any ) {
202
- dispatchFyllutMellomlagring ( { type : 'error' , error : 'CREATE FAILED ' } ) ;
202
+ dispatchFyllutMellomlagring ( { type : 'error' , error : 'CREATE_FAILED ' } ) ;
203
203
logger ?. error ( 'Failed to create mellomlagring' , error ) ;
204
204
}
205
205
} ;
@@ -223,10 +223,15 @@ const SendInnProvider = ({
223
223
logger ?. info ( `${ innsendingsId } : Mellomlagring was updated` ) ;
224
224
dispatchFyllutMellomlagring ( { type : 'update' , response } ) ;
225
225
return response ;
226
- } catch ( error ) {
227
- dispatchFyllutMellomlagring ( { type : 'error' , error : 'UPDATE FAILED' } ) ;
228
- logger ?. error ( `${ innsendingsId } : Failed to update mellomlagring` , error as Error ) ;
229
- throw error ;
226
+ } catch ( error : any ) {
227
+ if ( error . status === 404 ) {
228
+ dispatchFyllutMellomlagring ( { type : 'error' , error : 'UPDATE_FAILED_NOT_FOUND' } ) ;
229
+ throw error ;
230
+ } else {
231
+ dispatchFyllutMellomlagring ( { type : 'error' , error : 'UPDATE_FAILED' } ) ;
232
+ logger ?. error ( `${ innsendingsId } : Failed to update mellomlagring` , error as Error ) ;
233
+ throw error ;
234
+ }
230
235
}
231
236
} ;
232
237
@@ -239,10 +244,15 @@ const SendInnProvider = ({
239
244
const response = await deleteSoknad ( appConfig , innsendingsId ) ;
240
245
logger ?. info ( `${ innsendingsId } : Mellomlagring was deleted` ) ;
241
246
return response ;
242
- } catch ( error ) {
243
- dispatchFyllutMellomlagring ( { type : 'error' , error : 'DELETE FAILED' } ) ;
244
- logger ?. error ( `${ innsendingsId } : Failed to delete mellomlagring` , error as Error ) ;
245
- throw error ;
247
+ } catch ( error : any ) {
248
+ if ( error . status === 404 ) {
249
+ dispatchFyllutMellomlagring ( { type : 'error' , error : 'DELETE_FAILED_NOT_FOUND' } ) ;
250
+ throw error ;
251
+ } else {
252
+ dispatchFyllutMellomlagring ( { type : 'error' , error : 'DELETE_FAILED' } ) ;
253
+ logger ?. error ( `${ innsendingsId } : Failed to delete mellomlagring` , error as Error ) ;
254
+ throw error ;
255
+ }
246
256
}
247
257
} ;
248
258
@@ -273,14 +283,21 @@ const SendInnProvider = ({
273
283
window . location . href = redirectLocation ;
274
284
}
275
285
return response ;
276
- } catch ( submitError ) {
277
- logger ?. error ( `${ innsendingsId } : Failed to submit, will try to store changes` , submitError as Error ) ;
278
- try {
279
- await updateSoknad ( appConfig , form , submission , currentLanguage , translation , innsendingsId ) ;
280
- dispatchFyllutMellomlagring ( { type : 'error' , error : 'SUBMIT FAILED' } ) ;
281
- } catch ( updateError ) {
282
- logger ?. error ( `${ innsendingsId } : Failed to update mellomlagring after a failed submit` , updateError as Error ) ;
283
- dispatchFyllutMellomlagring ( { type : 'error' , error : 'SUBMIT AND UPDATE FAILED' } ) ;
286
+ } catch ( submitError : any ) {
287
+ if ( submitError . status === 404 ) {
288
+ dispatchFyllutMellomlagring ( { type : 'error' , error : 'SUBMIT_FAILED_NOT_FOUND' } ) ;
289
+ } else {
290
+ logger ?. error ( `${ innsendingsId } : Failed to submit, will try to store changes` , submitError as Error ) ;
291
+ try {
292
+ await updateSoknad ( appConfig , form , submission , currentLanguage , translation , innsendingsId ) ;
293
+ dispatchFyllutMellomlagring ( { type : 'error' , error : 'SUBMIT_FAILED' } ) ;
294
+ } catch ( updateError ) {
295
+ logger ?. error (
296
+ `${ innsendingsId } : Failed to update mellomlagring after a failed submit` ,
297
+ updateError as Error ,
298
+ ) ;
299
+ dispatchFyllutMellomlagring ( { type : 'error' , error : 'SUBMIT_AND_UPDATE_FAILED' } ) ;
300
+ }
284
301
}
285
302
}
286
303
} else {
0 commit comments