此文档创建于 2024/5/13
fail()
fail
is a function that throws a rescueable error. It has the following usage:
-
make the current target fail
-
indicate that a help function has failed to complete, but is fine to be rescueable/not fatal (which is a useful assumption for downstream ruleset libraries)
Examples
import * as NM from 'https://github.com/thautwarm/nomake/raw/v0.1.5/mod.ts' function operationTolerantToFailures() { // ... NM.fail('the operation failed') } NM.target( { name: 'output.txt', deps: ['input.txt'], async build() { await NM.allowFailAsync( // trail async () => { await operationTolerantToFailures(); }, async () => { console.log('the operation failed, but it is fine') // go to the alternative path }) } })
Usage
import * as NM from 'https://github.com/thautwarm/nomake/raw/v0.1.5/mod.ts'
function helper()
{
NM.fail('the helper function failed')
}