prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  Add more debugging information
  I am running a custom Python model in MLServer, and it fails with an error. The error itself is not interesting, what's important is that MLServer gives very little helpful information to debug it.
  
  After sending a request with grpcurl here is the entire response:
  ````
  ERROR:
    Code: Unknown
    Message: Unexpected <class 'TypeError'>: list indices must be integers or slices, not str
  ````
  No stack trace, no line numbers or class names. The only thing that appears in the logs is
  > scv2-mlserver-1  | 2022-10-19 09:10:44,218 [mlserver.grpc] INFO - /inference.GRPCInferenceService/ModelInfer
  
  Would be great if MLServer propagated more debugging info to the response message and to the log.
  
  </issue>
  <code>
  [start of mlserver/grpc/utils.py]
  1 import grpc
  2 
  3 from typing import Callable, Dict, Tuple
  4 from fastapi import status
  5 
  6 from grpc import ServicerContext
  7 
  8 from .logging import logger
  9 from ..errors import MLServerError
  10 
  11 
  12 STATUS_CODE_MAPPING = {
  13     status.HTTP_400_BAD_REQUEST: grpc.StatusCode.INVALID_ARGUMENT,
  14     status.HTTP_404_NOT_FOUND: grpc.StatusCode.NOT_FOUND,
  15     status.HTTP_422_UNPROCESSABLE_ENTITY: grpc.StatusCode.FAILED_PRECONDITION,
  16     status.HTTP_500_INTERNAL_SERVER_ERROR: grpc.StatusCode.INTERNAL,
  17 }
  18 
  19 
  20 def to_headers(context: ServicerContext) -> Dict[str, str]:
  21     metadata = context.invocation_metadata()
  22     if hasattr(context, "trailing_metadata"):
  23         # NOTE: Older versions of `grpcio` (e.g. `grpcio==1.34.0`) don't expose
  24         # access to the trailing metadata on the service side
  25         metadata += context.trailing_metadata()
  26     headers = {}
  27     for metadatum in metadata:
  28         headers[metadatum.key] = metadatum.value
  29 
  30     return headers
  31 
  32 
  33 def to_metadata(headers: Dict[str, str]) -> Tuple[Tuple[str, str], ...]:
  34     return tuple((key.lower(), value) for key, value in headers.items())
  35 
  36 
  37 def _grpc_status_code(err: MLServerError):
  38     return STATUS_CODE_MAPPING.get(err.status_code, grpc.StatusCode.UNKNOWN)
  39 
  40 
  41 def handle_mlserver_error(f: Callable):
  42     async def _inner(self, request, context):
  43         try:
  44             return await f(self, request, context)
  45         except MLServerError as err:
  46             logger.error(err)
  47             await context.abort(code=_grpc_status_code(err), details=str(err))
  48 
  49     return _inner
  50
  [end of mlserver/grpc/utils.py]
  </code>
  
  I need you to solve this issue by generating a single patch file that I can apply directly to this repository using git apply. Please respond with a single patch file in the following format.
  <patch>
  diff --git a/file.py b/file.py
  --- a/file.py
  +++ b/file.py
  @@ -1,27 +1,35 @@
   def euclidean(a, b):
  -    while b:
  -        a, b = b, a % b
  -    return a
  +    if b == 0:
  +        return a
  +    return euclidean(b, a % b)
   
   
   def bresenham(x0, y0, x1, y1):
       points = []
       dx = abs(x1 - x0)
       dy = abs(y1 - y0)
  -    sx = 1 if x0 < x1 else -1
  -    sy = 1 if y0 < y1 else -1
  -    err = dx - dy
  +    x, y = x0, y0
  +    sx = -1 if x0 > x1 else 1
  +    sy = -1 if y0 > y1 else 1
   
  -    while True:
  -        points.append((x0, y0))
  -        if x0 == x1 and y0 == y1:
  -            break
  -        e2 = 2 * err
  -        if e2 > -dy:
  -            err -= dy
  -            x0 += sx
  -        if e2 < dx:
  -            err += dx
  -            y0 += sy
  +    if dx > dy:
  +        err = dx / 2.0
  +        while x != x1:
  +            points.append((x, y))
  +            err -= dy
  +            if err < 0:
  +                y += sy
  +                err += dx
  +            x += sx
  +    else:
  +        err = dy / 2.0
  +        while y != y1:
  +            points.append((x, y))
  +            err -= dx
  +            if err < 0:
  +                x += sx
  +                err += dy
  +            y += sy
  +
  +    points.append((x, y))
       return points
  
  </patch>
golden_diff: diff --git a/mlserver/grpc/utils.py b/mlserver/grpc/utils.py
  --- a/mlserver/grpc/utils.py
  +++ b/mlserver/grpc/utils.py
  @@ -43,7 +43,10 @@
           try:
               return await f(self, request, context)
           except MLServerError as err:
  -            logger.error(err)
  +            logger.exception(err)
               await context.abort(code=_grpc_status_code(err), details=str(err))
  +        except Exception as err:
  +            logger.exception(err)
  +            await context.abort(code=grpc.StatusCode.INTERNAL, details=str(err))
   
       return _inner
  
verification_info: {"golden_diff": "diff --git a/mlserver/grpc/utils.py b/mlserver/grpc/utils.py\n--- a/mlserver/grpc/utils.py\n+++ b/mlserver/grpc/utils.py\n@@ -43,7 +43,10 @@\n         try:\n             return await f(self, request, context)\n         except MLServerError as err:\n-            logger.error(err)\n+            logger.exception(err)\n             await context.abort(code=_grpc_status_code(err), details=str(err))\n+        except Exception as err:\n+            logger.exception(err)\n+            await context.abort(code=grpc.StatusCode.INTERNAL, details=str(err))\n \n     return _inner\n", "issue": "Add more debugging information\nI am running a custom Python model in MLServer, and it fails with an error. The error itself is not interesting, what's important is that MLServer gives very little helpful information to debug it.\r\n\r\nAfter sending a request with grpcurl here is the entire response:\r\n````\r\nERROR:\r\n  Code: Unknown\r\n  Message: Unexpected <class 'TypeError'>: list indices must be integers or slices, not str\r\n````\r\nNo stack trace, no line numbers or class names. The only thing that appears in the logs is\r\n> scv2-mlserver-1  | 2022-10-19 09:10:44,218 [mlserver.grpc] INFO - /inference.GRPCInferenceService/ModelInfer\r\n\r\nWould be great if MLServer propagated more debugging info to the response message and to the log.\n", "before_files": [{"content": "import grpc\n\nfrom typing import Callable, Dict, Tuple\nfrom fastapi import status\n\nfrom grpc import ServicerContext\n\nfrom .logging import logger\nfrom ..errors import MLServerError\n\n\nSTATUS_CODE_MAPPING = {\n    status.HTTP_400_BAD_REQUEST: grpc.StatusCode.INVALID_ARGUMENT,\n    status.HTTP_404_NOT_FOUND: grpc.StatusCode.NOT_FOUND,\n    status.HTTP_422_UNPROCESSABLE_ENTITY: grpc.StatusCode.FAILED_PRECONDITION,\n    status.HTTP_500_INTERNAL_SERVER_ERROR: grpc.StatusCode.INTERNAL,\n}\n\n\ndef to_headers(context: ServicerContext) -> Dict[str, str]:\n    metadata = context.invocation_metadata()\n    if hasattr(context, \"trailing_metadata\"):\n        # NOTE: Older versions of `grpcio` (e.g. `grpcio==1.34.0`) don't expose\n        # access to the trailing metadata on the service side\n        metadata += context.trailing_metadata()\n    headers = {}\n    for metadatum in metadata:\n        headers[metadatum.key] = metadatum.value\n\n    return headers\n\n\ndef to_metadata(headers: Dict[str, str]) -> Tuple[Tuple[str, str], ...]:\n    return tuple((key.lower(), value) for key, value in headers.items())\n\n\ndef _grpc_status_code(err: MLServerError):\n    return STATUS_CODE_MAPPING.get(err.status_code, grpc.StatusCode.UNKNOWN)\n\n\ndef handle_mlserver_error(f: Callable):\n    async def _inner(self, request, context):\n        try:\n            return await f(self, request, context)\n        except MLServerError as err:\n            logger.error(err)\n            await context.abort(code=_grpc_status_code(err), details=str(err))\n\n    return _inner\n", "path": "mlserver/grpc/utils.py"}]}