Coverage Report

Created: 2025-07-23 06:53

/src/spotify-json/include/spotify/json/decode_exception.hpp
Line
Count
Source (jump to first uncovered line)
1
/*
2
 * Copyright (c) 2015-2016 Spotify AB
3
 *
4
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
5
 * use this file except in compliance with the License. You may obtain a copy of
6
 * the License at
7
 *
8
 * http://www.apache.org/licenses/LICENSE-2.0
9
 *
10
 * Unless required by applicable law or agreed to in writing, software
11
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13
 * License for the specific language governing permissions and limitations under
14
 * the License.
15
 */
16
17
#pragma once
18
19
#include <stdexcept>
20
#include <string>
21
#include <utility>
22
23
#include <spotify/json/detail/macros.hpp>
24
25
namespace spotify {
26
namespace json {
27
28
/**
29
 * decode_exception objects are thrown when decoding fails, for example if the
30
 * JSON is invalid, or if the JSON doesn't conform to the specified schema.
31
 */
32
class decode_exception final : public std::runtime_error {
33
 public:
34
  explicit decode_exception(const char *what, size_t offset = 0);
35
  decode_exception(decode_exception &&exception, size_t offset);
36
37
0
  size_t offset() const {
38
0
    return _offset;
39
0
  }
40
41
 private:
42
  size_t _offset;
43
};
44
45
}  // namespace json
46
}  // namespace spotify