summaryrefslogtreecommitdiff
path: root/include/io/zlib_error.h
blob: 1ecb50e553e9210ca7a1d2f138cb75beed4bf7da (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#ifndef ZLIB_ERROR_H_INCLUDED
#define ZLIB_ERROR_H_INCLUDED

#include <stdexcept>
#include <zlib.h>

///Exception thrown in case zlib encounters a problem
class zlib_error : public std::runtime_error
{
public:
    const int errcode;

    explicit zlib_error(const char* msg, int errcode):
        std::runtime_error(msg
                         ? std::string(zError(errcode)) + ": " + msg
                         : zError(errcode)),
        errcode(errcode)
    {}
};

#endif // ZLIB_ERROR_H_INCLUDED