@@ -7,8 +7,6 @@ import config from "config";
77const queue = "submission" ;
88const worker = "submit" ;
99
10- const ERROR_CODE = "SUBMIT_ERROR" ;
11-
1210const logger = pino ( ) . child ( {
1311 queue,
1412 worker,
@@ -43,10 +41,8 @@ export async function submitHandler(job: Job<SubmitJob>) {
4341 }
4442 return ;
4543 } catch ( e : any ) {
46- logger . error ( { jobId, err : e , errorCode : ERROR_CODE } , `post to ${ url } job: ${ id } failed with ${ e . cause ?? e . message } ` ) ;
47-
4844 if ( e . response ) {
49- logger . error ( { jobId, err : e . response . error } ) ;
45+ logger . error ( { jobId, errorCode : "SUBMIT_RESPONSE_ERROR" , err : e . response . data } , ` ${ jobId } POST to ${ url } failed` ) ;
5046 const { message, name, code, response } = e ;
5147 const { status, data } = response ;
5248 throw {
@@ -59,13 +55,17 @@ export async function submitHandler(job: Job<SubmitJob>) {
5955 }
6056
6157 if ( e . request ) {
62- logger . error ( jobId , `post to ${ url } request could not be sent, see database for error` ) ;
58+ logger . error ( { jobId, errorCode : "SUBMIT_REQUEST_ERROR" , e } , `post to ${ url } request could not be sent` ) ;
59+ throw e ;
6360 }
6461
6562 // @ts -ignore
6663 if ( e . cause instanceof AggregateError ) {
6764 throw { errors : e . cause . errors } ;
6865 }
66+
67+ logger . error ( { jobId, err : e , errorCode : "SUBMIT_ERROR_UNKNOWN" } , `post to ${ url } job: ${ id } failed with ${ e . cause ?? e . message ?? e } ` ) ;
68+
6969 throw e ;
7070 }
7171}
0 commit comments