userver: userver/compression/error.hpp Source File
Loading...
Searching...
No Matches
error.hpp
1#pragma once
2
3#include <stdexcept>
4
5#include <fmt/format.h>
6
7USERVER_NAMESPACE_BEGIN
8
9namespace compression {
10
11/// Base class for decompression errors
12class DecompressionError : public std::runtime_error {
13 using std::runtime_error::runtime_error;
14};
15
16/// Decompressed data size exceeds the limit
17class TooBigError : public DecompressionError {
18 public:
19 TooBigError() : DecompressionError("Decompressed data exceeds the limit") {}
20};
21
22class ErrWithCode : public DecompressionError {
23 public:
24 explicit ErrWithCode(const char* errName)
25 : DecompressionError(fmt::format("Decompression failed: {}", errName)) {}
26};
27
28} // namespace compression
29
30USERVER_NAMESPACE_END