BioC++ core-0.7.0
The Modern C++ libraries for Bioinformatics.
 
Loading...
Searching...
No Matches
exception.hpp
Go to the documentation of this file.
1// -----------------------------------------------------------------------------------------------------
2// Copyright (c) 2022 deCODE Genetics
3// Copyright (c) 2006-2020, Knut Reinert & Freie Universität Berlin
4// Copyright (c) 2016-2020, Knut Reinert & MPI für molekulare Genetik
5// This file may be used, modified and/or redistributed under the terms of the 3-clause BSD-License
6// shipped with this file and also available at: https://github.com/biocpp/biocpp-core/blob/main/LICENSE.md
7// -----------------------------------------------------------------------------------------------------
8
14#pragma once
15
16#include <concepts>
17#include <stdexcept>
18#include <string>
19
20#include <bio/core.hpp>
21
22namespace bio::alphabet
23{
24
27{
29 invalid_char_assignment(std::string const & type_name, char const wrong_char) :
30 std::runtime_error{std::string{"Assigning "} +
31 (std::isprint(wrong_char) ? std::string("\"") + std::string(1, wrong_char) + "\""
32 : std::to_string((int)wrong_char)) +
33 " to an alphabet of type " + type_name +
34 " would incur information loss. If you want implicit conversion, use "
35 "bio::alphabet::assign_char instead of bio::alphabet::assign_char_strict."}
36 {}
37
39 invalid_char_assignment(std::string const & type_name, std::convertible_to<char> auto const wrong_char) :
40 invalid_char_assignment(type_name, static_cast<char>(wrong_char))
41 {}
42};
43
44} // namespace bio::alphabet
Provides platform and dependency checks.
The alphabet module's namespace.
Definition: aa10li.hpp:23
An exception typically thrown by bio::alphabet::assign_char_strict.
Definition: exception.hpp:27
invalid_char_assignment(std::string const &type_name, std::convertible_to< char > auto const wrong_char)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: exception.hpp:39
invalid_char_assignment(std::string const &type_name, char const wrong_char)
Constructor that takes the type name and the failed character as arguments.
Definition: exception.hpp:29