search for: handletypederror

Displaying 6 results from an estimated 6 matches for "handletypederror".

2016 Feb 03
2
[RFC] Error handling in LLVM libraries.
...ot;In object file '" << ObjectName << "', " << EC.message(); } }; TypedError processArchive(Archive &A) { TypedError Err; for (auto &Obj : A) { auto Err = processObject(Obj); if (auto E2 = catchTypedErrors(std::move(Err), handleTypedError<ObjectError>([&](std::unique_ptr<ObjectError> OE) { OE->ArchiveName = A.getName(); return TypedError(std::move(OE)); })) return E2; } } In this example, any error (whether an ObjectError or something else) will be intercepted by the 'catchT...
2016 Feb 03
2
[RFC] Error handling in LLVM libraries.
...the handler and how is it handled? > > Sorry - that was a bad example to choose: That was actually showcasing > failure, not success. Success looks like this: > > TypedError bar() { > TypedError Err = foo; > if (auto E2 = > catchTypedErrors(std::move(Err), > handleTypedError<MyError>([&](std::unique_ptr<MyError> M) { > // Deal with 'M' somehow. > return TypedError(); > })) > return E2; > > // Proceed with 'bar' if 'Err' is handled. > } > > A key observation is that catchTyped...
2016 Feb 03
6
[RFC] Error handling in LLVM libraries.
...” of the handler, now what is a failure of the handler and how is it handled? Sorry - that was a bad example to choose: That was actually showcasing failure, not success. Success looks like this: TypedError bar() { TypedError Err = foo; if (auto E2 = catchTypedErrors(std::move(Err), handleTypedError<MyError>([&](std::unique_ptr<MyError> M) { // Deal with 'M' somehow. return TypedError(); })) return E2; // Proceed with 'bar' if 'Err' is handled. } A key observation is that catchTypedErrors itself returns an error. It has to,...
2016 Feb 03
2
[RFC] Error handling in LLVM libraries.
...gt;> >> Sorry - that was a bad example to choose: That was actually showcasing >> failure, not success. Success looks like this: >> >> TypedError bar() { >> TypedError Err = foo; >> if (auto E2 = >> catchTypedErrors(std::move(Err), >> handleTypedError<MyError>([&](std::unique_ptr<MyError> M) { >> // Deal with 'M' somehow. >> return TypedError(); >> })) >> return E2; >> >> // Proceed with 'bar' if 'Err' is handled. >> } >> >>...
2016 Feb 03
13
[RFC] Error handling in LLVM libraries.
...or. class MyCustomSubError : public TypedErrorInfo<MyCustomSubError, MyCustomError> { public: // Extends MyCustomError, adds new members. }; 3. A set of utility functions that use the custom RTTI system to inspect and handle typed errors. For example 'catchAllTypedErrors' and 'handleTypedError' cooperate to handle error instances in a type-safe way: TypedError foo() { if (SomeFailureCondition) return make_typed_error<MyCustomError>(); } TypedError Err = foo(); catchAllTypedErrors(std::move(Err), handleTypedError<MyCustomError>( [](std::unique_ptr<MyCusto...
2016 Feb 03
2
[RFC] Error handling in LLVM libraries.
...rInfo<MyCustomSubError, MyCustomError> { >> public: >> // Extends MyCustomError, adds new members. >> }; >> >> 3. A set of utility functions that use the custom RTTI system to inspect and handle typed errors. For example 'catchAllTypedErrors' and 'handleTypedError' cooperate to handle error instances in a type-safe way: >> >> TypedError foo() { >> if (SomeFailureCondition) >> return make_typed_error<MyCustomError>(); >> } >> >> TypedError Err = foo(); >> >> catchAllTypedErrors(std::move...