blob: 54a57ea0f7dce70c3416e7731753c78f1fbd1a98 [file] [log] [blame]
Artem Senicheve8837d52020-06-07 11:59:04 +03001// SPDX-License-Identifier: Apache-2.0
2// Copyright (C) 2020 YADRO
Artem Senichevafc73732020-05-09 19:04:51 +03003
4#pragma once
5
6#include <zlib.h>
7
8#include <exception>
9#include <string>
10
Artem Senicheve8837d52020-06-07 11:59:04 +030011/**
12 * @class ZlibException
13 * @brief zLib exception.
Artem Senichevafc73732020-05-09 19:04:51 +030014 */
15class ZlibException : public std::exception
16{
17 public:
18 /** @brief File operation types. */
19 enum Operation
20 {
Artem Senicheve8837d52020-06-07 11:59:04 +030021 create,
22 write,
23 close
Artem Senichevafc73732020-05-09 19:04:51 +030024 };
25
Artem Senicheve8837d52020-06-07 11:59:04 +030026 /**
27 * @brief Constructor.
Artem Senichevafc73732020-05-09 19:04:51 +030028 *
Artem Senicheve8837d52020-06-07 11:59:04 +030029 * @param[in] op type of operation
30 * @param[in] code zLib status code
31 * @param[in] fd zLib file descriptor
32 * @param[in] fileName file name
Artem Senichevafc73732020-05-09 19:04:51 +030033 */
34 ZlibException(Operation op, int code, gzFile fd,
35 const std::string& fileName);
36
37 // From std::exception
38 const char* what() const noexcept override;
39
40 private:
41 /** @brief Error description buffer. */
Artem Senicheve8837d52020-06-07 11:59:04 +030042 std::string errDesc;
Artem Senichevafc73732020-05-09 19:04:51 +030043};