• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

randombit / botan / 20698655531

04 Jan 2026 08:25PM UTC coverage: 90.416% (-0.009%) from 90.425%
20698655531

Pull #5124

github

web-flow
Merge 627aed356 into f283c5d29
Pull Request #5124: Cooperative Cancellation in PasswordHash

101700 of 112480 relevant lines covered (90.42%)

13010053.87 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

35.79
/src/lib/utils/exceptn.cpp
1
/*
2
* (C) 2017 Jack Lloyd
3
*
4
* Botan is released under the Simplified BSD License (see license.txt)
5
*/
6

7
#include <botan/exceptn.h>
8

9
#include <botan/internal/fmt.h>
10

11
namespace Botan {
12

13
std::string to_string(ErrorType type) {
×
14
   switch(type) {
×
15
      case ErrorType::Unknown:
×
16
         return "Unknown";
×
17
      case ErrorType::SystemError:
×
18
         return "SystemError";
×
19
      case ErrorType::NotImplemented:
×
20
         return "NotImplemented";
×
21
      case ErrorType::OutOfMemory:
×
22
         return "OutOfMemory";
×
23
      case ErrorType::InternalError:
×
24
         return "InternalError";
×
25
      case ErrorType::IoError:
×
26
         return "IoError";
×
27
      case ErrorType::InvalidObjectState:
×
28
         return "InvalidObjectState";
×
29
      case ErrorType::KeyNotSet:
×
30
         return "KeyNotSet";
×
31
      case ErrorType::OperationCanceled:
×
32
         return "OperationCanceled";
×
33
      case ErrorType::InvalidArgument:
×
34
         return "InvalidArgument";
×
35
      case ErrorType::InvalidKeyLength:
×
36
         return "InvalidKeyLength";
×
37
      case ErrorType::InvalidNonceLength:
×
38
         return "InvalidNonceLength";
×
39
      case ErrorType::LookupError:
×
40
         return "LookupError";
×
41
      case ErrorType::EncodingFailure:
×
42
         return "EncodingFailure";
×
43
      case ErrorType::DecodingFailure:
×
44
         return "DecodingFailure";
×
45
      case ErrorType::TLSError:
×
46
         return "TLSError";
×
47
      case ErrorType::HttpError:
×
48
         return "HttpError";
×
49
      case ErrorType::InvalidTag:
×
50
         return "InvalidTag";
×
51
      case ErrorType::RoughtimeError:
×
52
         return "RoughtimeError";
×
53
      case ErrorType::CommonCryptoError:
×
54
         return "CommonCryptoError";
×
55
      case ErrorType::Pkcs11Error:
×
56
         return "Pkcs11Error";
×
57
      case ErrorType::TPMError:
×
58
         return "TPMError";
×
59
      case ErrorType::DatabaseError:
×
60
         return "DatabaseError";
×
61
      case ErrorType::ZlibError:
×
62
         return "ZlibError";
×
63
      case ErrorType::Bzip2Error:
×
64
         return "Bzip2Error";
×
65
      case ErrorType::LzmaError:
×
66
         return "LzmaError";
×
67
   }
68

69
   // No default case in above switch so compiler warns
70
   return "Unrecognized Botan error";
×
71
}
72

73
Exception::Exception(std::string_view msg) : m_msg(msg) {}
467,128✔
74

75
Exception::Exception(std::string_view msg, const std::exception& e) : m_msg(fmt("{} failed with {}", msg, e.what())) {}
9,314✔
76

77
Exception::Exception(const char* prefix, std::string_view msg) : m_msg(fmt("{} {}", prefix, msg)) {}
9,886✔
78

79
Invalid_Argument::Invalid_Argument(std::string_view msg) : Exception(msg) {}
11,906✔
80

81
Invalid_Argument::Invalid_Argument(std::string_view msg, std::string_view where) :
×
82
      Exception(fmt("{} in {}", msg, where)) {}
×
83

84
Invalid_Argument::Invalid_Argument(std::string_view msg, const std::exception& e) : Exception(msg, e) {}
×
85

86
namespace {
87

88
std::string format_lookup_error(std::string_view type, std::string_view algo, std::string_view provider) {
6✔
89
   if(provider.empty()) {
6✔
90
      return fmt("Unavailable {} {}", type, algo);
6✔
91
   } else {
92
      return fmt("Unavailable {} {} for provider {}", type, algo, provider);
×
93
   }
94
}
95

96
}  // namespace
97

98
Lookup_Error::Lookup_Error(std::string_view type, std::string_view algo, std::string_view provider) :
6✔
99
      Exception(format_lookup_error(type, algo, provider)) {}
12✔
100

101
Internal_Error::Internal_Error(std::string_view err) : Exception("Internal error:", err) {}
30✔
102

103
Unknown_PK_Field_Name::Unknown_PK_Field_Name(std::string_view algo_name, std::string_view field_name) :
6✔
104
      Invalid_Argument(fmt("Unknown field '{}' for algorithm {}", field_name, algo_name)) {}
12✔
105

106
Invalid_Key_Length::Invalid_Key_Length(std::string_view name, size_t length) :
2✔
107
      Invalid_Argument(fmt("{} cannot accept a key of length {}", name, length)) {}
4✔
108

109
Invalid_IV_Length::Invalid_IV_Length(std::string_view mode, size_t bad_len) :
6,028✔
110
      Invalid_Argument(fmt("IV length {} is invalid for {}", bad_len, mode)) {}
12,056✔
111

112
Key_Not_Set::Key_Not_Set(std::string_view algo) : Invalid_State(fmt("Key not set in {}", algo)) {}
103,420✔
113

114
Operation_Canceled::Operation_Canceled(std::string_view oper) : Invalid_State(fmt("{} canceled", oper)) {}
6✔
115

116
PRNG_Unseeded::PRNG_Unseeded(std::string_view algo) : Invalid_State(fmt("PRNG {} not seeded", algo)) {}
23✔
117

118
Algorithm_Not_Found::Algorithm_Not_Found(std::string_view name) :
4,259✔
119
      Lookup_Error(fmt("Could not find any algorithm named '{}'", name)) {}
4,259✔
120

121
Provider_Not_Found::Provider_Not_Found(std::string_view algo, std::string_view provider) :
52,578✔
122
      Lookup_Error(fmt("Could not find provider '{}' for algorithm '{}'", provider, algo)) {}
52,578✔
123

124
Invalid_Algorithm_Name::Invalid_Algorithm_Name(std::string_view name) :
×
125
      Invalid_Argument(fmt("Invalid algorithm name: '{}'", name)) {}
×
126

127
Encoding_Error::Encoding_Error(std::string_view name) : Exception("Encoding error:", name) {}
42✔
128

129
Decoding_Error::Decoding_Error(std::string_view name) : Exception(name) {}
34,473✔
130

131
Decoding_Error::Decoding_Error(std::string_view category, std::string_view err) :
46✔
132
      Exception(fmt("{}: {}", category, err)) {}
92✔
133

134
Decoding_Error::Decoding_Error(std::string_view msg, const std::exception& e) : Exception(msg, e) {}
9,314✔
135

136
Invalid_Authentication_Tag::Invalid_Authentication_Tag(std::string_view msg) :
7,149✔
137
      Exception("Invalid authentication tag:", msg) {}
7,149✔
138

139
Stream_IO_Error::Stream_IO_Error(std::string_view err) : Exception("I/O error:", err) {}
206✔
140

141
System_Error::System_Error(std::string_view msg, int err_code) :
1✔
142
      Exception(fmt("{} error code {}", msg, err_code)), m_error_code(err_code) {}
2✔
143

144
Not_Implemented::Not_Implemented(std::string_view err) : Exception("Not implemented", err) {}
2,426✔
145

146
}  // namespace Botan
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc