> For the complete documentation index, see [llms.txt](https://docs.holium.com/ballot/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.holium.com/ballot/custom-actions/error-handling.md).

# Error Handling

If errors occur in your custom action handler, perform the following to route error information back to the UI for display and possible troubleshooting purposes.

The easiest way to demonstrate this is to take a look at the sample below; which generates an error and returns the action-result back to Ballot with associated effects.

Sample:

{% code overflow="wrap" %}

```hoon
/-  *plugin, ballot, res=resource, inv=invite-store
|%
++  on
  |=  [=bowl:gall store=state-1:ballot context=[booth-key=@t proposal-key=@t]]
  |%
    ++  action
      |=  [action-data=json payload=json]
      ^-  action-result
      =|  result=action-result
      :: force an error by:
      ::   1) setting the success property to %.n
      ::   2) giving a gift back to the booth owner ship (the one on which
      ::      this custom action is running) with an error reaction/effect
      =.  success.result  %.n
      =.  effects.result  (generate-error "testing custom action error. please ignore.")
      ::  return the action-result back to Ballot so the gift can be delivered
      result
    ++  generate-error
      |=  [err=tape]
      ^-  (list card:agent:gall)
      =/  context=json
      %-  pairs:enjs:format
      :~
        ['booth' s+booth-key.context]
        ['proposal' s+proposal-key.context]
      ==
      =/  error-data=json
      %-  pairs:enjs:format
      :~
        ['error' s+(crip err)]
      ==
      =/  error-effect=json
      %-  pairs:enjs:format
      :~
        ['resource' s+'proposal']
        ['effect' s+'error']
        ['data' error-data]
      ==
      ::  if we assume the custom action was 'invite-member', the error
      ::   should appears as follows:
      =/  effects=json
      %-  pairs:enjs:format
      :~
        ['action' s+'invite-member-reaction']
        ['context' context]
        ['effects' [%a [error-effect]~]]
      ==
      :~  [%give %fact [/booths]~ %json !>(effects)]
      ==
  --
--
```

{% endcode %}

<br>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.holium.com/ballot/custom-actions/error-handling.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
