You can so by using the context object given to your override#### function, it contains three types of error functions you can use, each expecting your custom message.
You can find an example in our migrations steps here. If you are not aware, we created a guide to help users migrate from the old agent to the new @forestadmin/agent since it can be arduous.
…But we’re using overrides, not hooks. And the functions you listed come from hooks and they are not available in overrides.
So the solution can be one of the following:
you export these functions in the overrides as well or
you export the result builder helper in the override functions (as you already do in the execute function of the action)
We don’t use hooks because we’re migrating from your express-sequelize lib and we have a lot of existing express middleware chains.
So we built some adapters to use our existing code. And we have some very complex functions in our middlewares and rewriting these is absolutely not an option
In your docs you say that we can use the override function also to interact with external APIs.
If we do this, how can we tell the outcome to the user if we can’t bring an error/success message in the forest UI???
the functions you listed come from hooks and they are not available in overrides.
I was expecting them to be available on any context, I don’t see why it wouldn’t be the case. I’ll take about this with the team.
There are 2 other ways to handle error messages with the new agent, you could simply throw the errors exported by @forestadmin/datasource-toolkit (a sub dependency of the agent, so not required to be define in your package.json)
Like so:
const { UnprocessableError } = require("@forestadmin/datasource-toolkit");
...
(context) => {
throw new UnprocessableError("This is a test");
Or you could use your own error classes and then define an error translator for the agent to use.