

本文属于机器翻译版本。若本译文内容与英语原文存在差异，则一律以英文原文为准。

# 开启调试消息
<a name="gateway-debug-messages"></a>

在网关开发期间，您可以开启调试消息以返回有关目标配置问题的详细信息，包括 lambda 函数错误、出口授权器错误、目标规范参数验证错误。开启调试消息后，如果调用网关时出现问题，响应将返回消息以帮助您进行调试。

 **要打开调试消息，请执行以下操作之一：**
+ 如果您使用 AgentCore CLI 创建网关，则调试会自动开启。
+ 如果您使用 Amazon 管理控制台创建网关，则默认情况下调试处于启用状态。该选项位于 “**网关详细信息” ** 部分的 “**其他配置**” 下。
+ 如果您使用 Amazon CLI 或 S Amazon DK，请将该`exceptionLevel`值设置为发出[CreateGateway](https://docs.amazonaws.cn/bedrock-agentcore-control/latest/APIReference/API_CreateGateway.html)或[UpdateGateway](https://docs.amazonaws.cn/bedrock-agentcore-control/latest/APIReference/API_UpdateGateway.html)请求`DEBUG`时的值。

完成网关调试后，您可以更新网关以关闭调试消息，这样发送给最终用户的消息仅显示未指定的内部错误。

 **要关闭调试消息，请执行以下操作之一：**
+ 在 Amazon 管理控制台中，在创建或编辑网关时展开 “**网关详细信息**” 部分**中的**其他配置，然后取消选中 “**异常级别调试**” 旁边的复选框。
+ 在 Amazon CLI 或 S Amazon DK 中，`UpdateGateway`发出`CreateGateway`或请求关闭调试时省略该`exceptionLevel`字段。

## 开启和关闭调试的网关响应示例
<a name="gateway-building-debug-ex"></a>

例如，假设用户没有权限调用网关所针对的 Lambda 函数。调用此函数的请求将返回不同的消息，具体取决于调试是开启还是关闭：
+  **调试开启 **-将在内容`text`字段和响应字段中返回详细的错误消息，如以下示例所示：`_meta`

  ```
  {
    "jsonrpc": "2.0",
    "id": 24,
    "result": {
      "content": [
        {
          "type": "text",
          "text": "Access denied while invoking Lambda function arn:aws:lambda:us-west-2:123456789012:function:TestGatewayLambda. Check the permissions on the Lambda function and Gateway execution role, and retry the request."
        }
      ],
      "_meta": {
        "debug": {
          "type": "text",
          "text": "Access denied while invoking Lambda function arn:aws:lambda:us-west-2:123456789012:function:TestGatewayLambda. Check the permissions on the Lambda function and Gateway execution role, and retry the request."
        }
      },
      "isError": true
    }
  }
  ```
+  **调试关闭 ** — 响应的内容`text`字段中将返回一条通用错误消息，如以下示例所示：

  ```
  {
    "jsonrpc": "2.0",
    "id": 24,
    "result": {
      "content": [
        {
          "type": "text",
          "text": "An internal error occurred. Please retry later."
        }
      ],
      "isError": true
    }
  }
  ```