0.6.0
C++ to UML diagram generator based on Clang
Loading...
Searching...
No Matches
error.h
Go to the documentation of this file.
1/**
2 * @file src/util/error.h
3 *
4 * Copyright (c) 2021-2025 Bartek Kryza <bkryza@gmail.com>
5 *
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 */
18#pragma once
19
20#include <stdexcept>
21
22#include "common/model/enums.h"
23
24namespace clanguml::error {
25
26class query_driver_no_paths : public std::runtime_error {
27public:
28 using std::runtime_error::runtime_error;
29};
30
31struct uml_alias_missing : public std::runtime_error {
32 uml_alias_missing(const std::string &message)
33 : std::runtime_error(message)
34 {
35 }
36};
37
38class compilation_database_error : public std::runtime_error {
39public:
40 using std::runtime_error::runtime_error;
41};
42
43class diagram_generation_error : public std::runtime_error {
44public:
46 std::string description)
47 : std::runtime_error{description}
48 , type_{type}
49 , name_{std::move(name)}
50 {
51 message_ =
52 fmt::format("Generation of {} diagram '{}' failed due to: {}",
53 diagram_type(), diagram_name(), description);
54 }
55
56 const char *what() const noexcept override { return message_.c_str(); }
57
58 const std::string &diagram_name() const noexcept { return name_; }
59 common::model::diagram_t diagram_type() const noexcept { return type_; }
60
61private:
63 std::string name_;
64
65 std::string message_;
66};
67
70};
71
74};
75
78};
79
80} // namespace clanguml::error