code: def handle_error(
      error, sagemaker_session, s3_base_uri, s3_kms_key, hmac_key
  ) -> int:
      """Handle all exceptions raised during remote function execution.
  
      Args:
          error (Exception): The error to be handled.
          sagemaker_session (sagemaker.session.Session): The underlying Boto3 session which
               AWS service calls are delegated to.
          s3_base_uri (str): S3 root uri to which resulting serialized exception will be uploaded.
          s3_kms_key (str): KMS key used to encrypt artifacts uploaded to S3.
          hmac_key (str): Key used to calculate hmac hash of the serialized exception.
      Returns :
          exit_code (int): Exit code to terminate current job.
      """
  
      failure_reason = repr(error)
      if isinstance(error, RemoteFunctionError):
          exit_code = DEFAULT_FAILURE_CODE
      else:
          error_number = getattr(error, "errno", DEFAULT_FAILURE_CODE)
          exit_code = _get_valid_failure_exit_code(error_number)
  
      _write_failure_reason_file(failure_reason)
  
      serialization.serialize_exception_to_s3(
          exc=error,
          sagemaker_session=sagemaker_session,
          s3_uri=s3_path_join(s3_base_uri, "exception"),
          hmac_key=hmac_key,
          s3_kms_key=s3_kms_key,
      )
  
      return exit_code
  
file_path: sagemaker-python-sdk/src/sagemaker/remote_function/errors.py
imports: from __future__ import absolute_import
  import os
  from tblib import pickling_support
  from sagemaker.s3 import s3_path_join
  import sagemaker.remote_function.core.serialization
label_desc: Use image node_id 3 for calling a global function with example usage: handle_error(error, sagemaker_session, s3_base_uri, s3_kms_key, hmac_key) and returns: exit_code