def handle_error()

in src/sagemaker_inference/transformer.py [0:0]


    def handle_error(context, inference_exception, trace):
        """Set context appropriately for error response.

        Args:
            context (mms.context.Context): The inference context.
            inference_exception (sagemaker_inference.errors.BaseInferenceToolkitError): An exception
                raised during inference, with information for the error response.
            trace (traceback): The stacktrace of the error.

        Returns:
            str: The error message and stacktrace from the exception.
        """
        context.set_response_status(
            code=inference_exception.status_code,
            phrase=utils.remove_crlf(inference_exception.phrase),
        )
        return ["{}\n{}".format(inference_exception.message, trace)]