Skip to content

Commit

Permalink
[Fix] if onerror handler is not set, rethrow the error
Browse files Browse the repository at this point in the history
  • Loading branch information
SunriseFox committed Sep 27, 2018
1 parent 6903c99 commit 8eae33d
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -677,6 +677,7 @@ The IMAP client has several events you can attach to by setting a listener
### Handling fatal error event

The invocation of `onerror` indicates an irrecoverable error. When `onerror` is fired, the connection is already closed, hence there's no need for further cleanup.
If no `onerror` is specified, the error will be thrown.

## Get your hands dirty

Expand Down
8 changes: 6 additions & 2 deletions dist/client.js

Large diffs are not rendered by default.

6 changes: 5 additions & 1 deletion src/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,11 @@ export default class Client {
clearTimeout(this._idleTimeout)

// propagate the error upwards
this.onerror && this.onerror(err)
if (this.onerror) {
this.onerror(err)
} else {
throw err
}
}

//
Expand Down

0 comments on commit 8eae33d

Please sign in to comment.