docs/current_docs/extending/modules/error-handling.mdx
Dagger modules handle errors in the same way as the language they are written in. This allows you to support any kind of error handling that your application requires. You can also use error handling to verify user input.
Here is an example Dagger Function that performs division and throws an error if the denominator is zero:
<Tabs groupId="language" queryString="sdk"> <TabItem value="go" label="Go">Error handling in Go modules follows typical Go error patterns with explicit error return values and if err != nil checks. You can also use error handling to verify user input.
Here is an example call for this Dagger Function:
<Tabs groupId="shell"> <TabItem value="System shell"> ```shell dagger -c 'divide 4 2' ``` </TabItem> <TabItem value="Dagger Shell"> ```shell title="First type 'dagger' for interactive mode." divide 4 2 ``` </TabItem> <TabItem value="Dagger CLI"> ```shell dagger call divide --a=4 --b=2 ``` </TabItem> </Tabs>The result will be:
2
Here is another example call for this Dagger Function, this time dividing by zero:
<Tabs groupId="shell"> <TabItem value="System shell"> ```shell dagger -c 'divide 4 0' ``` </TabItem> <TabItem value="Dagger Shell"> ```shell title="First type 'dagger' for interactive mode." divide 4 0 ``` </TabItem> <TabItem value="Dagger CLI"> ```shell dagger call divide --a=4 --b=0 ``` </TabItem> </Tabs>The result will be:
cannot divide by zero