From 257df96b12f38cba45751449dcd64ca712dd96c2 Mon Sep 17 00:00:00 2001 From: David Steele Date: Sun, 11 Nov 2018 18:06:09 -0500 Subject: [PATCH] Add THROW*_ON_SYS_ERROR* macros to test and throw system errors. These macros check the error result internally and are appropriate for system calls that won't return errors and so break coverage. --- doc/xml/release.xml | 4 ++++ src/common/error.h | 28 ++++++++++++++++++++++++++++ 2 files changed, 32 insertions(+) diff --git a/doc/xml/release.xml b/doc/xml/release.xml index 5122370e2..d687ce060 100644 --- a/doc/xml/release.xml +++ b/doc/xml/release.xml @@ -106,6 +106,10 @@

Construct Wait object in milliseconds instead of fractional seconds.

+ +

Add THROW*_ON_SYS_ERROR* macros to test and throw system errors.

+
+

Storage interface methods no longer declare the driver as const.

diff --git a/src/common/error.h b/src/common/error.h index 36946a4c8..282875a42 100644 --- a/src/common/error.h +++ b/src/common/error.h @@ -150,6 +150,34 @@ Throw an error when a system call fails #define THROWP_SYS_ERROR_FMT(errorType, ...) \ errorInternalThrowSysFmt(errno, errorType, __FILE__, __func__, __LINE__, __VA_ARGS__) +#define THROW_ON_SYS_ERROR(error, errorType, message) \ + do \ + { \ + if (error) \ + errorInternalThrowSys(errno, &errorType, __FILE__, __func__, __LINE__, message); \ + } while(0) + +#define THROW_ON_SYS_ERROR_FMT(error, errorType, ...) \ + do \ + { \ + if (error) \ + errorInternalThrowSysFmt(errno, &errorType, __FILE__, __func__, __LINE__, __VA_ARGS__); \ + } while(0) + +#define THROWP_ON_SYS_ERROR(error, errorType, message) \ + do \ + { \ + if (error) \ + errorInternalThrowSys(errno, errorType, __FILE__, __func__, __LINE__, message); \ + } while(0) + +#define THROWP_ON_SYS_ERROR_FMT(error, errorType, ...) \ + do \ + { \ + if (error) \ + errorInternalThrowSysFmt(errno, errorType, __FILE__, __func__, __LINE__, __VA_ARGS__); \ + } while(0) + #define THROW_SYS_ERROR_CODE(errNo, errorType, message) \ errorInternalThrowSys(errNo, &errorType, __FILE__, __func__, __LINE__, message) #define THROW_SYS_ERROR_CODE_FMT(errNo, errorType, ...) \