@@ -107,30 +107,43 @@ def run_resolver(
107107 self , method : RESOLVER , context : RESOLVER_CONTEXT , args : Tuple [str , Any ]
108108 ) -> Tuple [StatusCode , ResponseArtifact | None ]:
109109 id , payload = args
110+ statuscode : StatusCode = StatusCode .OK
111+ response : ResponseArtifact | None = None
112+ error : Any = None
113+
110114 try :
111- response = method (id , payload , context )
112- return StatusCode .OK , getAnswerArtifact (id , response )
115+ response = getAnswerArtifact (id , method (id , payload , context ))
113116 except NotAuthorizedException as e :
114- return StatusCode . NOT_AUTHORIZED , getErrorArtifact (
115- id , str ( e ), StatusCode .NOT_AUTHORIZED
116- )
117+ error = e
118+ statuscode = StatusCode .NOT_AUTHORIZED
119+ response = getErrorArtifact ( id , str ( e ), StatusCode . NOT_AUTHORIZED )
117120 except InvalidInputsException as e :
118- return StatusCode . INVALID_INPUTS , getErrorArtifact (
119- id , str ( e ), StatusCode .INVALID_INPUTS
120- )
121+ error = e
122+ statuscode = StatusCode .INVALID_INPUTS
123+ response = getErrorArtifact ( id , str ( e ), StatusCode . INVALID_INPUTS )
121124 except NoProcessingException :
122- return StatusCode .NO_PROCESSING , None
125+ statuscode = StatusCode .NO_PROCESSING
123126 except MethodNotFoundException as e :
124- return StatusCode . METHOD_NOT_FOUND , getErrorArtifact (
125- id , str ( e ), StatusCode .METHOD_NOT_FOUND
126- )
127+ error = e
128+ statuscode = StatusCode .METHOD_NOT_FOUND
129+ response = getErrorArtifact ( id , str ( e ), StatusCode . METHOD_NOT_FOUND )
127130 except Exception as e :
128- if self ._config .get (f"conf.{ self .name } .exiton5xx" ):
129- print ("Exiting due to 5xx error" , e , flush = True )
130- exit (1 )
131- return StatusCode .SERVER_ERROR , getErrorArtifact (
132- id , str (e ), StatusCode .SERVER_ERROR
133- )
131+ error = e
132+ statuscode = StatusCode .SERVER_ERROR
133+ response = getErrorArtifact (id , str (e ), StatusCode .SERVER_ERROR )
134+
135+ if self ._config .get (f"conf.{ self .name } .exiton5xx" ) and statuscode .value >= 500 :
136+ print ("Exiting due to 5xx error" , error , flush = True )
137+ exit (1 )
138+ if (
139+ self ._config .get (f"conf.{ self .name } .exiton4xx" )
140+ and statuscode .value >= 400
141+ and statuscode .value < 500
142+ ):
143+ print ("Exiting due to 5xx error" , error , flush = True )
144+ exit (1 )
145+
146+ return statuscode , response
134147
135148 def inputProcessor (self , message : Any ) -> StatusCode :
136149 bus = self ._busClass (
0 commit comments