APIs
Getting StartedExecution API ReferenceCustom Actions
Getting StartedCustom Actions ReferenceUsing external APIs in Custom ActionsFrequently encountered issues
- My application failed and I think it is my Custom Action, what do I do?
- I get an Error Message when executing my Custom Action
- My Custom Action code does not work
My application failed and I think it is my Custom Action, what do I do?
BRYTER Custom Actions has an event log which contains an entry for each time you execute a Custom Action as part of an Application. It is the best place to start to try and understand what went wrong.
Follow the steps outlined in Get a list of events for a custom action and you should be seeing the list of events. In many cases it will contain information which is useful for you to understand what went wrong.
Below is a sample for an error event which indicates that there is something wrong when trying to read JSON data.
[{
"createdAt": "2023-03-29 20:55:39.44709",
"name": "error",
"id": "BQ9cV4K1TTqCC_8_c26jjA",
"data": {
"error": {
"code": 500,
"message": "SyntaxError: Unexpected end of JSON input"
},
"logs": []
}
},]
I get an Error Message when executing my Custom Action
If you get an error message such as or similar
Then we advice you to follow the steps described above to verify the actions logs where more details are provided. If the logs are not helpful we also recommend you to include more details from your function code such as the example provided in our sample where some detailed logs are captured in case of error.
My Custom Action code does not work
Your Custom Action is setup correctly, but something is not correct with the code. It could be that a calculation is wrong, there is an invalid result returned or similar.
Regardless of the problem, one way to learn more is by adding log statements to your code.
Here is a sample BRYTER module enables users to add a list of numbers which are sent to an action to be doubled and then output the sum of all numbers.
Below is the code for a Custom Action which should double all items in a list.
function main(numbers: number): number {
return numbers
.map(num => num +2)
.reduce((partialSum, num) => partialSum + num, 0)
}
However when running this module the sum comes back as 12
when a user adds the number 1, 2 and 3. The double sum of those numbers is not 12, so there is something wrong here and we need to figure out if it is the sum or the doubling which fail. Below is one way to get more insights into what is going on.
function main(numbers: number[]): number {
const doubledList = numbers
.map(num => {
const result = num +2
console.log(`${num} x2 = ${result}`)
return result
})
console.log('doubled list', doubledList)
const sum = doubledList.reduce((partialSum, num) => partialSum + num, 0)
console.log('Sum', sum)
return sum
}
When looking at the event log, you will be seeing this:
[{
"createdAt": "2023-06-15 07:57:17.487392",
"name": "success",
"id": "BQ9cV4K1TTqCC_8_c26jjA",
"data": {
"timings": {
"duration": 419,
"startTime": 1686815837014
},
"logs": [{
"message": "1 x2 = 3",
"parameters": []
},
{
"message": "2 x2 = 4",
"parameters": []
},
{
"message": "3 x2 = 5",
"parameters": []
},
{
"message": "doubled list",
"parameters": [
[3, 4, 5]
]
},
{
"message": "Sum",
"parameters": [12]
}]
}
}]
When investigating, you will see that youβre adding 2 and not multiplying as expected. This was perhaps obvious from reading the code, however in more advanced cases this technique of logging will help you figure out what is going wrong in your action.
β Previous
Next β