1
1
---
2
2
sidebar_position : 6
3
- sidebar_label : Handle errors
3
+ sidebar_label : Debug & handle errors
4
4
description :
5
5
" Learn how to handle errors effectively to improve PromptQL's understanding and accuracy when interacting with your
6
6
custom business logic."
@@ -14,29 +14,69 @@ keywords:
14
14
import Tabs from " @theme/Tabs" ;
15
15
import TabItem from " @theme/TabItem" ;
16
16
17
- # Handle Errors with Lambda Connectors
17
+ # Debug and Handle Errors with Lambda Connectors
18
18
19
19
## Introduction
20
20
21
- By default, lambda connectors return a generic ` internal error ` message whenever an exception is encountered in your
22
- custom business logic and ** log the details of the error in the OpenTelemetry trace associated with the request** .
21
+ When developing with lambda connectors, understanding what went wrong — and why — is just as important as handling the
22
+ error itself. By default for security reasons, lambda connectors return a generic ` internal error ` message when exceptions occur, while the
23
+ full details are logged in the [ OpenTelemetry trace] ( #access-opentelemetry-traces ) for that request.
23
24
24
- The Native Data Connector specification identifies a
25
- [ valid set of status codes ] ( https://hasura.github.io/ndc-spec/specification/ error-handling.html ) which can be used to
26
- improve PromptQL's understanding of errors when they occur .
25
+ This page covers strategies for both ** debugging issues ** during development and ** handling errors ** effectively in
26
+ deployed connectors. You'll learn how to inspect traces, return custom error messages, and use supported error classes
27
+ to improve PromptQL's understanding and self-corrective capabilities .
27
28
28
- :::info How detailed should error messages be?
29
+ For a full list of supported status codes, refer to the
30
+ [ Native Data Connector error specification] ( https://hasura.github.io/ndc-spec/specification/error-handling.html ) .
29
31
30
- Exposing stack traces to end users is generally discouraged. Instead, administrators can review traces logged in the
31
- OpenTelemetry traces to access detailed stack trace information.
32
+ ## Debugging
32
33
33
- That said, the more clarity provided in an error message, the better PromptQL can self-correct and improve its
34
- understanding of the function. Clear, descriptive error messages allow PromptQL to learn from errors and provide more
35
- accurate interactions with your data over time.
34
+ ### Local development
35
+
36
+ As your connector is running inside a Docker container, any logs (i.e., ` console.log() ` , ` print() ` , or ` fmt.Println() ` )
37
+ from your custom business logic will be visible in the container's logs.
38
+
39
+ These logs are printed to your terminal when running the default ` ddn run docker-start ` command, can be viewed by
40
+ running ` docker logs <lambda_container_name> ` , or via Docker Desktop.
41
+
42
+ :::info Enable watch mode
43
+
44
+ We recommend enabling Compose Watch on your lambda connectors to create a shorter feedback loop during development. See
45
+ the guide [ here] ( /business-logic/dev-mode.mdx ) .
36
46
37
47
:::
38
48
39
- ## Return custom error messages
49
+ ### Deployed connectors
50
+
51
+ For deployed connectors, you can use the DDN CLI to locate the connector's build ID and then output the logs to your
52
+ terminal.
53
+
54
+ #### Step 1. List all builds for a connector
55
+
56
+ Start by entering a project directory.
57
+
58
+ ``` ddn title="For example, to get the list of builds for a connector named my_ts:"
59
+ ddn connector build get --connector-name my_ts
60
+ ```
61
+
62
+ ``` plaintext title="Which will return a list of all builds for my_ts:"
63
+ +---------------------+----------+--------------------------------------+---------------+------------------------------------------------------------------------------+------------------------------------------------------------------------------+----------------+-----------------------+
64
+ | CREATION TIME | SUBGRAPH | CONNECTORBUILD ID | CONNECTOR | READ URL | WRITE URL | STATUS | HUBCONNECTOR |
65
+ +---------------------+----------+--------------------------------------+---------------+------------------------------------------------------------------------------+------------------------------------------------------------------------------+----------------+-----------------------+
66
+ | 13 Apr 25 19:07 PDT | app | b336c2f5-de3a-4d11-9f88-52578f3d8d92 | my_ts | https://service-b336c2f5-de3a-4d11-9f88-52578f3d8d92-<project-id>.a.run.app | https://service-b336c2f5-de3a-4d11-9f88-52578f3d8d92-<project-id>.a.run.app | deploy_success | hasura/nodejs:v1.13.0 |
67
+ +---------------------+----------+--------------------------------------+---------------+------------------------------------------------------------------------------+------------------------------------------------------------------------------+----------------+-----------------------+
68
+ ```
69
+
70
+ #### Step 2. Fetch the logs for a build
71
+
72
+ ``` ddn title="Then, use the CONNECTORBUILD ID to fetch the logs:"
73
+ ddn connector build logs b336c2f5-de3a-4d11-9f88-52578f3d8d92
74
+ ```
75
+
76
+ The [ ` ddn connector build logs ` command] ( /reference/cli/commands/ddn_connector_build_logs.mdx ) supports tailing logs
77
+ along with other customizations.
78
+
79
+ ## Returning custom error messages
40
80
41
81
Lambda connectors allow you to throw classes of errors with your own custom message and metadata to indicate specific
42
82
error conditions. These classes are designed to provide clarity in error handling when PromptQL interacts with your data
@@ -138,7 +178,18 @@ func FunctionHello(ctx context.Context, state *types.State, arguments *HelloArgu
138
178
139
179
</Tabs >
140
180
141
- ## Access OpenTelemetry traces
181
+ :::info How detailed should error messages be?
182
+
183
+ Exposing stack traces to end users is generally discouraged. Instead, administrators can review traces logged in the
184
+ OpenTelemetry traces to access detailed stack trace information.
185
+
186
+ That said, the more clarity provided in an error message, the better PromptQL can self-correct and improve its
187
+ understanding of the function. Clear, descriptive error messages allow PromptQL to learn from errors and provide more
188
+ accurate interactions with your data over time.
189
+
190
+ :::
191
+
192
+ ### Access OpenTelemetry traces { #access - opentelemetry - traces }
142
193
143
194
Traces — complete with your custom error messages — are available for each request. You can find these in the ` Insights `
144
195
tab of your project's console. These traces help you understand how PromptQL is interacting with your data and where
0 commit comments