Constructs a Task that resolves with a rejected value.
This API is still experimental, so it may change or be removed in future versions. You should not rely on it for production applications.
Constructs a Task that resolves with a rejected value.
The value is computed eagerly. If you need the value to be computed only when the task is ran you'll have to use the task
function.
const { rejected } = require('folktale/concurrency/task');
try {
const result = await rejected('hello').run().promise();
throw 'never happens';
} catch (error) {
$ASSERT(error == 'hello');
}
rejected(reason) {
return new Task(resolver => resolver.reject(reason));
}