blob: b1473016bb26fec3f39ce80870b5bc994545b884 [file] [log] [blame]
Artem Senichevafc73732020-05-09 19:04:51 +03001/**
2 * @brief zLib exception.
3 *
4 * This file is part of HostLogger project.
5 *
6 * Copyright (c) 2020 YADRO
7 *
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
11 *
12 * http://www.apache.org/licenses/LICENSE-2.0
13 *
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
19 */
20
21#pragma once
22
23#include <zlib.h>
24
25#include <exception>
26#include <string>
27
28/** @class ZlibException
29 * @brief zLib exception.
30 */
31class ZlibException : public std::exception
32{
33 public:
34 /** @brief File operation types. */
35 enum Operation
36 {
37 Create,
38 Write,
39 Close
40 };
41
42 /** @brief Constructor.
43 *
44 * @param[in] op - type of operation
45 * @param[in] code - zLib status code
46 * @param[in] fd - zLib file descriptor
47 * @param[in] fileName - file name
48 */
49 ZlibException(Operation op, int code, gzFile fd,
50 const std::string& fileName);
51
52 // From std::exception
53 const char* what() const noexcept override;
54
55 private:
56 /** @brief Error description buffer. */
57 std::string what_;
58};