Error handling in Custom UI resolver

What’s the appropriate way of returning errors from the Custom UI resolver?

As far as I can see, error handling is not documented at all (https://developer.atlassian.com/platform/forge/runtime-reference/custom-ui-resolver/). I couldn’t find error handling in the sample apps either.

I tried all kinds of things, and the best I can do is:

resolver.define('myHandler', async (args) => {
  throw new Error('Hello');
});

… which yields:

{
    "data": {
        "invokeExtension": {
            "success": false,
            "response": null,
            "contextToken": null,
            "errors": [
                {
                    "message": "There was an error invoking the function - Hello",
                    "extensions": {
                        "errorType": "INVOCATION_FAILED",
                        "statusCode": 400,
                        "__typename": "GenericMutationErrorExtension"
                    },
                    "__typename": "MutationError"
                }
            ],
            "__typename": "InvokeExtensionResponse"
        }
    },
    "extensions": {
        "gateway": {
            "request_id": "c182cd41e8f8cdf3",
            "crossRegion": false,
            "edgeCrossRegion": false,
            "deprecatedFieldsUsed": []
        }
    }
}

That’s completely useless. Any real-life application needs meaningful error handling. Yes, I can see that my “Hello” made it somewhere deep into the error message, and I know I could parse it off of that. But it’s pretty atrocious, I can’t imagine doing that for some realistic needs.

So, what’s the correct way of doing it? I couldn’t find the docs anywhere, and it doesn’t seem to be present in any of the public Atlassian libraries. Looks like it’s all proprietary code, with no documentation.

For comparison, here’s how you can do error handling in a GraphQL environment: Error handling - Apollo GraphQL Docs.

Is Atlassian using some library for the GraphQL stuff? How does error handling work there?

If it’s a proprietary tool, where is the documentation for that?

4 Likes

I’m dealing with the same issue. Can anyone point me to documentation or examples of error handling in custom resolvers?