From 3078f519aa4a633c62746aa4bf1a86a5225e06ce Mon Sep 17 00:00:00 2001 From: leandor Date: Sun, 6 Nov 2016 01:49:52 -0300 Subject: [PATCH] (#18) Better error messages Included boost::format for generating formatted strings in the exception messages. --- src/papi/lz4/module.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/papi/lz4/module.cpp b/src/papi/lz4/module.cpp index 965d0a6..7225636 100644 --- a/src/papi/lz4/module.cpp +++ b/src/papi/lz4/module.cpp @@ -2,11 +2,14 @@ #include "module.h" +#include + #include #include #include #include +using boost::format; py::bytes lz4::compress(const py::bytes& buffer) { @@ -18,8 +21,9 @@ py::bytes lz4::compress(const py::bytes& buffer) auto res = api::compress_default(source, dest); - if (res == 0) { - throw std::exception("compression failed"); + if (res <= 0) { + const auto errorMsg = (format("LZ4: compression failed with result code: %1%") % res).str(); + throw std::exception(errorMsg.c_str()); } return py::bytes(dest.data(), res);