Error logging and debugging
Logging errors is a crucial part of the error handling mechanism. Errors are logged into a dedicated error table defined by you, capturing key information for debugging and analysis. Take the information that you currently have in the context of the function and log it using the operations properties to the table by defining the data to be logged in the records property.
The full error coming back from the backend system should be logged.
Expose error tables in Jigx Builder to help with troubleshooting.
Define a datasource against the error tables.
Error logging configuration
When configuring REST errors, several system expressions and variables can be used. These variables allow you to dynamically log and handle errors based on the context of the function call. The following context is available to write to the error table, using =@ctx.variable.value:
commandId
Unique id logged for the item on the commandQueue. The id matches the id in the entity table.
correlationId
The unique identifier that appears in the app. It is used in troubleshooting to help identify specific entries in the logs and to follow the user's journey while using the solution in the app. By filtering logs using this ID, you can troubleshoot issues more effectively.
entity
The specified table where the error context is logged
error
message: string
title: string
description: string
details: string
icon: string
table: string
notification: boolean
parameters
Specify any of the parameters in the function to be logged to the error table.
request
method: string
url: string
headers: Record<string, string>
body:string
Buffer
response
ok: boolean
status: number
statusText: string
headers: Record<string, string>
body: any
solution
id: SolutionId
name: SolutionName
organizationId: OrganizationId
settings:
custom: Record<string, unknown>
user
id: string
email: string
displayName: string
avatarUrl: string
phone: string
isVerified: boolean
settings: Record<string, unknown>
error:
# Configure details for each erro status code.
- when: =@ctx.response.status = 403
# Configure the error table and the data to log to the table,
# in the error section of the function.
operations:
- type: operation.upsert-merge
table: =@ctx.entity & "_error"
records:
'={ "id": @ctx.commandId, "type": "System Offline", "response": @ctx.response,
"request": @ctx.request, "user": @ctx.user, "solution": @ctx.solution,
"entity": @ctx.entity, "correlationId": @ctx.correlationId}'
timestamp: remoteSystemTimestamp # Call the error details from the dedicated error table in a datasource.
# Use the datasource to configure jigs to action the error, e.g. retry.
type: datasource.sqlite
options:
provider: DATA_PROVIDER_LOCAL
entities:
- entity: datasync-error
query: SELECT
id,
json_extract(err.data, '$.response.ok') as ok,
json_extract(err.data, '$.response.status') as status,
json_extract(err.data, '$.response.statusText') as statusText,
json_extract(err.data, '$.response.headers') as headers,
json_extract(err.data, '$.response.body') as body,
json_extract(err.data, '$.screen') as screen,
json_extract(err.data, '$.type') as type
FROM
[datasync-error] AS errLast updated
Was this helpful?