diff options
author | David Robillard <d@drobilla.net> | 2023-04-03 08:51:58 -0400 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2023-04-05 09:45:15 -0400 |
commit | b8638fb5c51bcb4d51c6d13c2ee1e4734dfdd616 (patch) | |
tree | 538dc4c909648d45d91a33008b797ba0eccc2de7 /src/try.h | |
parent | f93c3fdd6c7d6ca61bec55d3c1ffae7e7c793913 (diff) | |
download | serd-b8638fb5c51bcb4d51c6d13c2ee1e4734dfdd616.tar.gz serd-b8638fb5c51bcb4d51c6d13c2ee1e4734dfdd616.tar.bz2 serd-b8638fb5c51bcb4d51c6d13c2ee1e4734dfdd616.zip |
Improve writer error handling
Diffstat (limited to 'src/try.h')
-rw-r--r-- | src/try.h | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/src/try.h b/src/try.h new file mode 100644 index 00000000..f49ae05f --- /dev/null +++ b/src/try.h @@ -0,0 +1,21 @@ +// Copyright 2011-2023 David Robillard <d@drobilla.net> +// SPDX-License-Identifier: ISC + +#ifndef SERD_SRC_TRY_H +#define SERD_SRC_TRY_H + +#define TRY(st, exp) \ + do { \ + if (((st) = (exp))) { \ + return (st); \ + } \ + } while (0) + +#define TRY_FAILING(st, exp) \ + do { \ + if (((st) = (exp)) > SERD_FAILURE) { \ + return (st); \ + } \ + } while (0) + +#endif // SERD_SRC_TRY_H |