MCPcopy Create free account
hub / github.com/Effect-TS/effect / throws

Function throws

packages/effect/test/utils/assert.ts:104–121  ·  view source on GitHub ↗
(thunk: () => void, error?: string | Error | ((u: unknown) => undefined), ..._: Array<never>)

Source from the content-addressed store, hash-verified

102}
103
104export function throws(thunk: () => void, error?: string | Error | ((u: unknown) => undefined), ..._: Array<never>) {
105 try {
106 thunk()
107 } catch (e) {
108 if (error !== undefined) {
109 if (Predicate.isString(error)) {
110 assertInstanceOf(e, Error)
111 strictEqual(e.message, error)
112 } else if (Predicate.isError(error)) {
113 deepStrictEqual(e, error)
114 } else {
115 error(e)
116 }
117 }
118 return
119 }
120 fail("Expected to throw an error")
121}
122
123export async function throwsAsync(
124 thunk: () => Promise<void>,

Callers 15

Option.test.tsFile · 0.90
expectMessageFunction · 0.90
DateTime.test.tsFile · 0.90
Result.test.tsFile · 0.90
Chunk.test.tsFile · 0.90
Optic.test.tsFile · 0.90
BigDecimal.test.tsFile · 0.90
assertGraphErrorFunction · 0.90
Graph.test.tsFile · 0.90
Redacted.test.tsFile · 0.90
Cron.test.tsFile · 0.90

Calls 5

assertInstanceOfFunction · 0.70
strictEqualFunction · 0.70
deepStrictEqualFunction · 0.70
failFunction · 0.70
errorFunction · 0.50

Tested by 10

expectMessageFunction · 0.72
assertGraphErrorFunction · 0.72
assertUnsupportedSchemaFunction · 0.72
assertUnsupportedSchemaFunction · 0.72
expectErrorFunction · 0.72
expectErrorFunction · 0.72
expectInvalidPayloadFunction · 0.72
errorFromFunction · 0.72
expectErrorFunction · 0.72