Skip to content

Commit

Permalink
End group in core.group regardless of error thrown
Browse files Browse the repository at this point in the history
  • Loading branch information
jclem committed Aug 29, 2019
1 parent 8f9992c commit 92e6443
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions packages/core/src/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,14 @@ export function endGroup(): void {
*/
export async function group<T>(name: string, fn: () => Promise<T>): Promise<T> {
startGroup(name)
const result = await fn()
endGroup()

let result: T

try {
result = await fn()
} finally {
endGroup()
}

return result
}

0 comments on commit 92e6443

Please sign in to comment.