Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
Co-Authored-By: Ankur Oberoi <aoberoi@gmail.com>
  • Loading branch information
stevengill and aoberoi committed Mar 26, 2020
1 parent 0b56f25 commit f9c07d9
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 11 deletions.
6 changes: 3 additions & 3 deletions docs/_advanced/error_handling.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ order: 1
---

<div class="section-content">
*Note: Since `Bolt@2.x`, error handling has improved! View the [migration guide for V2](https://slack.dev/bolt/tutorial/migration-v2) to learn more.*
*Note: Since v2, error handling has improved! View the [migration guide for V2](https://slack.dev/bolt/tutorial/migration-v2) to learn about the changes.*

If an error occurs in a listener, it’s recommended you handle it directly with a `try`/`catch`. However, there still may be cases where errors slip through the cracks. By default, these errors will be logged to the console. To handle them yourself, you can attach a global error handler to your app with the `error(fn)` method.
If an error occurs in a listener, it’s recommended you handle it directly with a `try`/`catch`. However, there still may be cases where errors slip through the cracks. By default, these errors will be logged to the console. To handle them yourself, you can attach a global error handler to your app with the `app.error(fn)` method.
</div>

```javascript
app.error((error) => {
// Check the details of the error to handle cases where you should retry sending a message or stop the app
console.error(error);
});
```
```
2 changes: 1 addition & 1 deletion docs/_advanced/middleware_global.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Both global and listener middleware must call `await next()` to pass control of

As an example, let's say your app should only respond to users identified with a corresponding internal authentication service (an SSO provider or LDAP, for example). You may define a global middleware that looks up a user record in the authentication service and errors if the user is not found.

*Note: Since `Bolt@2.x`, global middleware was updated to support `async` functions! View the [migration guide for V2](https://slack.dev/bolt/tutorial/migration-v2) to learn more.*
*Note: Since v2, global middleware was updated to support `async` functions! View the [migration guide for V2](https://slack.dev/bolt/tutorial/migration-v2) to learn about the changes.*
</div>

```javascript
Expand Down
2 changes: 1 addition & 1 deletion docs/_advanced/middleware_listener.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ But of course, you can write your own middleware for more custom functionality.

As an example, let’s say your listener should only deal with messages from humans. You can write a listener middleware that excludes any bot messages.

*Note: Since `Bolt@2.x`, listener middleware was updated to support `async` functions! View the [migration guide for V2](https://slack.dev/bolt/tutorial/migration-v2) to learn more.*
*Note: Since v2, listener middleware was updated to support `async` functions! View the [migration guide for V2](https://slack.dev/bolt/tutorial/migration-v2) to learn about the changes.*
</div>

```javascript
Expand Down
2 changes: 1 addition & 1 deletion docs/_basic/listening_actions.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Actions can be filtered on an `action_id` of type string or RegExp object. `acti

You’ll notice in all `action()` examples, `ack()` is used. It is required to call the `ack()` function within an action listener to acknowledge that the event was received from Slack. This is discussed in the [acknowledging events section](#acknowledge).

*Note: Since `Bolt@2.x`, message shortcuts (previously message actions) now use the `shortcut()` method instead of the `action()` method. View the [migration guide for V2](https://slack.dev/bolt/tutorial/migration-v2) to learn more.*
*Note: Since v2, message shortcuts (previously message actions) now use the `shortcut()` method instead of the `action()` method. View the [migration guide for V2](https://slack.dev/bolt/tutorial/migration-v2) to learn about the changes.*
</div>

```javascript
Expand Down
10 changes: 5 additions & 5 deletions docs/_tutorials/migration_v2.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ permalink: /tutorial/migration-v2
# Migrating to v2.x

<div class="section-content">
This guide will walk you through the process of updating your app from using `bolt@v1.x` to `bolt@2.x`.
This guide will walk you through the process of updating your app from using `@slack/bolt@1.x` to `@slack/bolt@2.x`. There are a few changes you'll need to make but for most apps, these changes can be applied in 5 - 15 minutes.
</div>

---
Expand Down Expand Up @@ -66,8 +66,8 @@ app.error((error) => {

Other error related changes include:

- When your listener doesn’t call `ack` within the 3 section time limit, we log the failure instead of throwing an error.
- If you have multiple errors at once when running middleware, Bolt for Javascript will return a wrapper error with a `code` parameter of `slack_bolt_multiple_listener_error` and an `original` parameter that contains an array of all of the errors.
- When your listener doesn’t call `ack` within the 3 second time limit, we log the failure instead of throwing an error.
- If multiple errors occur when processing multiple listeners for a single event, Bolt for Javascript will return a wrapper error with a `code` property of `ErrorCode.MultipleListenerError` and an `originals` property that contains an array of the individual errors.


## Message Shortcuts
Expand All @@ -77,7 +77,7 @@ Other error related changes include:
Before:

```javascript
app.action('message-action-callback', ({action, ack, context}) => {
app.action({ callback_id: 'message-action-callback' }, ({action, ack, context}) => {
ack();
// Do stuff
})
Expand Down Expand Up @@ -119,4 +119,4 @@ async function noBotMessages({ message, next }) {
// Post processing goes here
}
}
```
```

0 comments on commit f9c07d9

Please sign in to comment.