Skip to content

Commit 735f904

Browse files
committed
fix(std/results): $try results
1 parent 3f82147 commit 735f904

File tree

1 file changed

+9
-2
lines changed
  • packages/std/src/results/utils

1 file changed

+9
-2
lines changed

packages/std/src/results/utils/try.ts

+9-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { BlobType } from '../../shared'
1+
import { isPromise, type BlobType } from '../../shared'
22

33
import { resultTags } from '../tag'
44
import { handleCatch, handleThen } from './internal/handlers'
@@ -37,7 +37,14 @@ export function $try<R, R2, R3, R4, C extends Std.ErrorValues[] = []>(
3737
try {
3838
const result = body().next()
3939

40-
return handleThen(result, ...additionalCauses) as BlobType
40+
if (isPromise(result)) {
41+
return handleThen(
42+
result.then(v => v.value),
43+
...additionalCauses
44+
) as BlobType
45+
}
46+
47+
return handleThen(result.value, ...additionalCauses) as BlobType
4148
} catch (rawError) {
4249
return handleCatch(rawError, ...additionalCauses) as BlobType
4350
}

0 commit comments

Comments
 (0)