numerical-collection-cpp 0.10.0
A collection of algorithms in numerical analysis implemented in C++
Loading...
Searching...
No Matches
exception.h
Go to the documentation of this file.
1/*
2 * Copyright 2021 MusicScience37 (Kenta Kabashima)
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of 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,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
20#pragma once
21
22#include <stdexcept>
23#include <string>
24#include <string_view>
25
26#include <fmt/base.h>
27#include <fmt/format.h>
28
30
31namespace num_collect {
32inline namespace base {
33
34namespace impl {
35
43[[nodiscard]] inline auto format_error(std::string_view message,
44 util::source_info_view source_info) -> std::string {
45 return fmt::format(FMT_STRING("{} ({}:{}:{})"), message,
46 source_info.file_path(), source_info.line(), source_info.column());
47}
48
49} // namespace impl
50
57class num_collect_exception : public std::runtime_error {
58public:
67 explicit num_collect_exception(std::string_view message,
69 : std::runtime_error(impl::format_error(message, source_info)) {}
70};
71
79
87
99
107
108} // namespace base
109} // namespace num_collect
Class of exceptions thrown when an algorithm fails to solve a problem.
Definition exception.h:95
Class of exceptions thrown when an error occurs in file operations.
Definition exception.h:103
num_collect_exception(std::string_view message, util::source_info_view source_info=util::source_info_view())
Constructor.
Definition exception.h:67
Class of exceptions thrown when an argument in a function is invalid.
Definition exception.h:83
num_collect_exception(std::string_view message, util::source_info_view source_info=util::source_info_view())
Constructor.
Definition exception.h:67
num_collect_exception(std::string_view message, util::source_info_view source_info=util::source_info_view())
Constructor.
Definition exception.h:67
Class of exceptions thrown when a precondition is not satisfied.
Definition exception.h:75
num_collect_exception(std::string_view message, util::source_info_view source_info=util::source_info_view())
Constructor.
Definition exception.h:67
Class to hold information of source codes.
Namespace of internal implementations.
Definition exception.h:34
auto format_error(std::string_view message, util::source_info_view source_info) -> std::string
Format error.
Definition exception.h:43
Namespace of definitions common in this project.
Namespace of num_collect source codes.
STL namespace.
Definition of source_info_view class.