Skip to content

Commit de25267

Browse files
authored
Fresh look doc pages and Error Handling (windmill-labs#420)
1 parent 2d91102 commit de25267

28 files changed

+97
-56
lines changed

docs/apps/0_toolbar.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,10 @@ View the [YAML or JSON representation](../core_concepts/13_json_schema_and_parsi
4848

4949
Hub Compatible JSON: View the JSON / YAML representation of the app in a format that is compatible with the [Windmill Hub](https://hub.windmill.dev/).
5050

51+
![Submit App JSON to Hub](../assets/apps/1_app_toolbar/export_hub.png "Submit App JSON to Hub")
52+
53+
![Submit App JSON to Hub](../assets/apps/1_app_toolbar/submit_app.png "Submit App JSON to Hub")
54+
5155
### App Inputs
5256

5357
The app inputs menu displays a list of all the inputs of each component. A toggle allows you to display only resources inputs, enabling you to easily configure your third-party resources for an app imported from the Hub, for example:
440 KB
Loading
204 KB
Loading
30.9 KB
Loading
Binary file not shown.
Binary file not shown.

docs/cli_local_dev/1_vscode-extension/index.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ In the settings menu, set the remote url, workspace name and [token](../../core_
7070

7171
1. Install the [extension](https://marketplace.visualstudio.com/items?itemName=windmill-labs.windmill).
7272

73-
2. Enter your Windmill remote URL and [token](../../core_concepts/4_webhooks/index.md#user-token), so the extension can execute scripts and flows on your workspace.
73+
2. Enter your Windmill remote URL and [token](../../core_concepts/4_webhooks/index.mdx#user-token), so the extension can execute scripts and flows on your workspace.
7474

7575
3. From any script file, use `> Windmill: Run preview in the current editor` or Ctrl+Enter and Shift+Enter to generate the UI preview (provided that the script meets the [few rules](../../core_concepts/13_json_schema_and_parsing/index.md#json-schema-in-windmill) required by Windmill).
7676

docs/core_concepts/10_error_handling/index.mdx

Lines changed: 59 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -8,40 +8,38 @@ There are 5 ways to do error handling in Windmill.
88

99
One way to handle errors in Windmill is by using the `try/catch` block within a Script. This method is not specific to Windmill and can be used in any programming language that supports exception handling.
1010

11-
Here is an example in TypeScript:
11+
Here is an example in [TypeScript](../../getting_started/0_scripts_quickstart/1_typescript_quickstart/index.mdx):
1212

1313
```ts
14-
export async function main(): Promise<void> {
15-
try {
16-
// Code that might throw an exception
17-
const result = await fetchData(); // Asynchronous operation that may throw an exception
18-
console.log('Data:', result); // If no exception occurs, display the data
19-
} catch (error) {
20-
// Code to handle the exception
21-
console.error('An error occurred:', error);
22-
}
23-
}
24-
25-
async function fetchData(): Promise<string> {
26-
// Simulating an asynchronous operation that may throw an exception
27-
return new Promise((resolve, reject) => {
28-
// Intentionally throwing an exception
29-
setTimeout(() => {
30-
reject(new Error('Failed to fetch data'));
31-
}, 2000);
32-
});
14+
// Define the main function which will handle errors using try/catch
15+
export async function main() {
16+
try {
17+
// Your code that might throw errors goes here
18+
// For example, let's simulate a fetch request
19+
const response = await fetch("https://api.example.com/data");
20+
const data = await response.json();
21+
22+
// Return the result if everything goes well
23+
return data;
24+
} catch (error) {
25+
// Handle errors that might occur during the fetch operation
26+
console.error("An error occurred:", error);
27+
28+
// Return a custom error object or message
29+
return { error: "An error occurred while fetching data." };
30+
}
3331
}
3432
```
3533

3634
<br />
3735

38-
![Try Catch](./try_catch.png.webp)
36+
![Try Catch](./try_catch.png)
3937

4038
## Flows' Error Handlers
4139

42-
The Error Handler is a special flow step that is executed when an error occurs within a flow.
40+
The Error Handler is a special [flow](../../flows/1_flow_editor.mdx) step that is executed when an error occurs within a flow.
4341

44-
If defined, the error handler will take as input, the result of the step that errored (which has its error in the 'error field').
42+
If defined, the error handler will take as input the result of the step that errored (which has its error in the 'error field').
4543

4644
<video
4745
className="border-2 rounded-xl object-cover w-full h-full dark:border-gray-800"
@@ -59,9 +57,22 @@ If defined, the error handler will take as input, the result of the step that er
5957
/>
6058
</div>
6159

60+
### Special Case: Error Handling in Flows
61+
62+
There are other tricks to do Error handling in flows, see:
63+
64+
<div class="grid grid-cols-2 gap-6 mb-4">
65+
<DocCard
66+
title="Error Handling in Flows"
67+
description="There are four ways to handle errors in Windmill flows."
68+
href="/docs/flows/error_handling"
69+
/>
70+
</div>
71+
72+
6273
## Schedules' Error Handlers
6374

64-
Add a special script or flow to execute in case of an error in your scheduled script or flow.
75+
Add a special script or flow to execute in case of an error in your [scheduled](../1_scheduling/index.md) script or flow.
6576

6677
You can pick the Slack pre-set schedule error handler or define your own.
6778

@@ -82,11 +93,29 @@ You can pick the Slack pre-set schedule error handler or define your own.
8293

8394
## Workspace Error Handler
8495

85-
You can define a script to be executed automatically in case of error in the workspace.
96+
### Workspace Error Handler on Slack
97+
98+
On [Cloud, Self-Host Pro & Enterprise Editions](../../misc/7_plans_details/index.mdx), you can [connect workspace to Slack](../../integrations/slack.mdx) and enable an automated error handler on a given channel.
8699

87-
From the workspace settings, pick the "Error Handler" tab and pick a script.
100+
<iframe
101+
style={{ aspectRatio: '16/9' }}
102+
src="https://www.youtube.com/embed/6QPONDONd5k?vq=1080p"
103+
title="Workspace Error Handler on Slack"
104+
frameBorder="0"
105+
allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share"
106+
allowFullScreen
107+
className="border-2 rounded-xl object-cover w-full dark:border-gray-800"
108+
></iframe>
109+
110+
<br/>
88111

89-
![Workspace Error Handler](./workspace_error_handler.png.webp)
112+
### Custom Workspace Error Handler
113+
114+
You can also define a custom script or flow to be executed automatically in case of error in the workspace.
115+
116+
From the workspace settings, on the "Error Handler" tab and pick a script or flow.
117+
118+
![Workspace Error Handler](./workspace_error_handler.png "Workspace Error Handler")
90119

91120
The following args will be passed to the error handler:
92121

@@ -102,7 +131,7 @@ The Error handler will be executed by the automatically created group g/error_ha
102131
Here is a template for your workspace error handler:
103132

104133
```ts
105-
// Global / workspace error handler template
134+
// Workspace error handler template
106135

107136
export async function main(
108137
path: string, // The path of the script or flow that errored
@@ -123,7 +152,7 @@ export async function main(
123152

124153
## Instance Error Handler
125154

126-
You can define a script to be executed automatically in case of error in your instance.
155+
You can define a script to be executed automatically in case of error in your instance (all workspaces).
127156

128157
This Superadmin Error handler is defined by setting the path to the script to be executed as an env variable to all servers using: `GLOBAL_ERROR_HANDLER_PATH_IN_ADMINS_WORKSPACE`.
129158

@@ -156,16 +185,4 @@ export async function main(
156185
console.log(error);
157186
return error;
158187
}
159-
```
160-
161-
## Special Case: Error Handling in Flows
162-
163-
For more information on Error handling in flows, see:
164-
165-
<div class="grid grid-cols-2 gap-6 mb-4">
166-
<DocCard
167-
title="Error Handling in Flows"
168-
description="There are four ways to handle errors in Windmill flows."
169-
href="/docs/flows/error_handling"
170-
/>
171-
</div>
188+
```
Loading
Binary file not shown.

0 commit comments

Comments
 (0)