# QPromise::fail
Since: 0.1.0
QPromise<T>::fail(Function onRejected) -> QPromise<T>
Shorthand to promise.then(nullptr, onRejected)
for handling errors in promise chains,
similar to the native C++ catch
statement (opens new window):
promise.fail([](const MyException& error) {
// {...}
}).fail([](const QException& error) {
// {...}
}).fail([](const std::exception& error) {
// {...}
}).fail([]() {
// {...} catch-all
});
See also: QPromise::then