@@ -10,6 +10,7 @@ import {
10
10
assembleSendInnSoknadBody ,
11
11
byteArrayToObject ,
12
12
isMellomLagringEnabled ,
13
+ isNotFound ,
13
14
sanitizeInnsendingsId ,
14
15
validateInnsendingsId ,
15
16
} from './helpers/sendInn' ;
@@ -57,12 +58,11 @@ const sendInnSoknad = {
57
58
`Feil ved kall til SendInn. ${ getErrorMessage } ` ,
58
59
true ,
59
60
) ;
60
- if (
61
- sendInnResponse . status === 404 ||
62
- responseError ?. [ 'http_response_body' ] ?. errorCode === 'illegalAction.applicationSentInOrDeleted'
63
- ) {
61
+ if ( isNotFound ( sendInnResponse , responseError ) ) {
62
+ logger . info ( `${ sanitizedInnsendingsId } : Not found. Failed to get` , responseError ) ;
64
63
return res . sendStatus ( 404 ) ;
65
64
}
65
+
66
66
logger . debug ( 'Failed to fetch data from SendInn' ) ;
67
67
return next ( responseError ) ;
68
68
}
@@ -115,6 +115,7 @@ const sendInnSoknad = {
115
115
next ( err ) ;
116
116
}
117
117
} ,
118
+
118
119
put : async ( req : Request , res : Response , next : NextFunction ) => {
119
120
try {
120
121
const idportenPid = getIdportenPid ( req ) ;
@@ -152,8 +153,18 @@ const sendInnSoknad = {
152
153
logger . debug ( 'Successfylly updated data in SendInn' ) ;
153
154
res . json ( await sendInnResponse . json ( ) ) ;
154
155
} else {
156
+ const responseError = await responseToError (
157
+ sendInnResponse ,
158
+ `Feil ved kall til SendInn. ${ putErrorMessage } ` ,
159
+ true ,
160
+ ) ;
161
+ if ( isNotFound ( sendInnResponse , responseError ) ) {
162
+ logger . info ( `${ sanitizedInnsendingsId } : Not found. Failed to update` , responseError ) ;
163
+ return res . sendStatus ( 404 ) ;
164
+ }
165
+
155
166
logger . debug ( 'Failed to update data in SendInn' ) ;
156
- next ( await responseToError ( sendInnResponse , `Feil ved kall til SendInn. ${ putErrorMessage } ` , true ) ) ;
167
+ next ( responseError ) ;
157
168
}
158
169
} catch ( err ) {
159
170
next ( err ) ;
@@ -192,8 +203,18 @@ const sendInnSoknad = {
192
203
const json = await sendInnResponse . json ( ) ;
193
204
res . json ( json ) ;
194
205
} else {
206
+ const responseError = await responseToError (
207
+ sendInnResponse ,
208
+ `Feil ved kall til SendInn. ${ deleteErrorMessage } ` ,
209
+ true ,
210
+ ) ;
211
+ if ( isNotFound ( sendInnResponse , responseError ) ) {
212
+ logger . info ( `${ sanitizedInnsendingsId } : Not found. Failed to delete` , responseError ) ;
213
+ return res . sendStatus ( 404 ) ;
214
+ }
215
+
195
216
logger . debug ( `Failed to delete soknad with innsendingsId ${ sanitizedInnsendingsId } ` ) ;
196
- next ( await responseToError ( sendInnResponse , `Feil ved kall til SendInn. ${ deleteErrorMessage } ` , true ) ) ;
217
+ next ( responseError ) ;
197
218
}
198
219
} catch ( err ) {
199
220
next ( err ) ;
0 commit comments