mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-21 23:20:20 +00:00
AK: Document the non-standard extensions in TRY
I'm not sure there's a material improvement from this patch. However, I've been reading the error handling code from multiple projects and was excited to see Serenity being able to handle assignment (`auto x = TRY(make_x())`) the same way as actions (`TRY(do_x())`). I think it's worth documenting that this is only possible due to non-standard extensions.
This commit is contained in:
parent
9fad23018a
commit
d989c50c90
Notes:
sideshowbarker
2024-07-18 03:35:30 +09:00
Author: https://github.com/paulherman 🔰 Commit: https://github.com/SerenityOS/serenity/commit/d989c50c90 Pull-request: https://github.com/SerenityOS/serenity/pull/15650 Reviewed-by: https://github.com/linusg
1 changed files with 5 additions and 0 deletions
5
AK/Try.h
5
AK/Try.h
|
@ -8,6 +8,11 @@
|
|||
|
||||
// NOTE: This macro works with any result type that has the expected APIs.
|
||||
// It's designed with AK::Result and AK::Error in mind.
|
||||
//
|
||||
// It depends on a non-standard C++ extension, specifically
|
||||
// on statement expressions [1]. This is known to be implemented
|
||||
// by at least clang and gcc.
|
||||
// [1] https://gcc.gnu.org/onlinedocs/gcc/Statement-Exprs.html
|
||||
|
||||
#define TRY(expression) \
|
||||
({ \
|
||||
|
|
Loading…
Reference in a new issue