--- title: "Catch HTTP Connector Errors" slug: "catch-http-connector-errors" updated: 2025-01-08T12:10:34Z published: 2025-01-08T12:10:34Z canonical: "support.tulip.co/catch-http-connector-errors" --- > ## Documentation Index > Fetch the complete documentation index at: https://support.tulip.co/llms.txt > Use this file to discover all available pages before exploring further. # 捕捉 HTTP 连接器错误 *了解捕捉 HTTP API 连接器错误的用例,以及如何记录错误和重试连接器功能。* ## HTTP 连接器错误类型 HTTP 协议标准中包含了对服务器响应代码和消息的要求,即 HT**TP 响应代码**和**HTTP 响应消息**。因此,有了标准的 HTTP 响应代码类或类别,以帮助最终用户直观地识别发生的错误类型。这些代码类别包括:**1xx*-**信息性响应**请求已收到,继续处理**2xx*-**成功**请求已成功收到、理解并接受**3xx*-**重定向**需要采取**进一步**行动才能完成请求**4xx*-**客户端错误**请求包含错误语法或无法满足**5xx*-**服务器错误服务器**未能满足明显有效的请求 最常见的错误代码是`404 - 未找到`或`500 - 内部服务器错误`。这些错误代码可能表明外部系统服务器出现故障、正在进行维护、服务出现问题或网络出现问题。 ## 举例说明:在应用程序中捕获 HTTP 错误 下面的示例详细介绍了如何配置应用程序以显示 HTTP 连接器函数错误。 ### 构建连接器函数 在连接器函数生成器中,你可以在连接器 Output 配置中映射 HTTP 错误代码和错误信息。这将把 HTTP 错误代码和错误信息作为连接器函数输出传递给 Tulip 应用程序。 1. 将 HTTP 状态字段映射到输出。![Connector Output Mapping 1.png](https://cdn.document360.io/7c6ff534-cad3-4fc8-9583-912c4016362f/Images/Documentation/Connector%20Output%20Mapping%201.png) 2. 给输出一个清晰明确的名称,然后重新运行连接器函数,测试输出是否正确显示。![Connector Output Mapping 2.png](https://cdn.document360.io/7c6ff534-cad3-4fc8-9583-912c4016362f/Images/Documentation/Connector%20Output%20Mapping%202.png){height="" width="""} 这将看起来像下面的示例:![Catch Connector Errors Overview.gif](https://cdn.document360.io/7c6ff534-cad3-4fc8-9583-912c4016362f/Images/Documentation/Catch%20Connector%20Errors%20Overview.gif){height="" width="""} ### 构建一个应用程序来处理连接器错误 在应用程序中使用连接器的输出信息来执行连接器错误处理。 #### 在应用程序触发器中运行连接器 使用 "**运行连接器功能 "**创建触发器操作。选择刚刚创建的连接器和函数,然后将结果保存为**变量**。![Run Connector Trigger - Error Catching.png](https://cdn.document360.io/7c6ff534-cad3-4fc8-9583-912c4016362f/Images/Documentation/Run%20Connector%20Trigger%20-%20Error%20Catching.png) HTTP 响应代码和消息现在可以在新的应用程序变量中作为引用。![HTTP Response Code as Variable.png](https://cdn.document360.io/7c6ff534-cad3-4fc8-9583-912c4016362f/Images/Documentation/HTTP%20Response%20Code%20as%20Variable.png) #### 在应用程序中可视化连接器响应 在显示整个**连接器响应**变量的应用程序步骤中放置一个变量部件。![Visualize connector response with variable widget.gif](https://cdn.document360.io/7c6ff534-cad3-4fc8-9583-912c4016362f/Images/Documentation/Visualize%20connector%20response%20with%20variable%20widget.gif) ### 构建连接器错误处理触发器 接下来,您可以使用 HTTP 响应代码在后续触发条件中执行应用程序级错误处理。 1. 创建一个新触发器来执行**连接器错误处理**。![Connector Error Handling Trigger.png](https://cdn.document360.io/7c6ff534-cad3-4fc8-9583-912c4016362f/Images/Documentation/Connector%20Error%20Handling%20Trigger.png){height="" width="""} 2. 创建一个条件,查找不正确的 HTTP 响应代码。在本例中,该条件查找**不等于**200 的响应:(Info) (Note) Many systems use a 200 response code as a good response, but it is best to check with the API endpoint provider or IT if all good responses will only be of code 200 ::: 3. ![Bad Response Code Trigger.png](https://cdn.document360.io/7c6ff534-cad3-4fc8-9583-912c4016362f/Images/Documentation/Bad%20Response%20Code%20Trigger.png){height="" width=""} 创建一个触发器动作,当满足条件时,即 HTTP 响应代码不正确时,触发器动作就会发生。 下面是应用程序中的样子:![HTTP Error Response Overview.gif](https://cdn.document360.io/7c6ff534-cad3-4fc8-9583-912c4016362f/Images/Documentation/HTTP%20Error%20Response%20Overview.gif) ## 进一步阅读 - [如何创建和配置 HTTP 连接器函数](/r230/docs/how-to-create-and-configure-an-http-connector-function) - [如何格式化 HTTP 连接器输出](/r230/docs/how-to-format-http-connector-outputs) - [在应用程序中使用 HTTP 连接器](/r230/docs/using-http-connectors-in-apps) **Output** An **output** is the transmission of data from a program to a data set.