Skip to content

Commit ce24dd6

Browse files
committed
Fixup scaffolding library error descriptions
To conform with more strict error checking in other language binding tests Signed-off-by: Martynas Gurskas <[email protected]>
1 parent 2d4c7f6 commit ce24dd6

File tree

4 files changed

+15
-7
lines changed

4 files changed

+15
-7
lines changed

cpp-tests/scaffolding_tests/coverall/lib_coverall.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ bool coverall::Coveralls::maybe_throw_complex(uint8_t input) {
9696
}
9797

9898
void coverall::Coveralls::panic(std::string message) {
99-
throw std::runtime_error("coveralls->panic()");
99+
throw std::runtime_error(message);
100100
}
101101

102102
void coverall::Coveralls::fallible_panic(std::string message) {

cpp-tests/scaffolding_tests/coverall/lib_coverall.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ namespace {
197197
namespace coverall_error {
198198
class TooManyHoles: public std::runtime_error {
199199
public:
200-
TooManyHoles() : TooManyHoles("") {}
200+
TooManyHoles() : TooManyHoles("The coverall has too many holes") {}
201201
TooManyHoles(const std::string &what_arg) : std::runtime_error(what_arg) {}
202202
};
203203
}

cpp-tests/scaffolding_tests/fixture_callbacks/lib_fixture_callbacks.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ std::optional<std::string> fixture_callbacks::RustGetters::get_option(std::share
1717
return foreign->get_option(v, argument_two);
1818
} catch (const fixture_callbacks::complex_error::ReallyBadArgument &e) {
1919
throw e;
20+
} catch (const fixture_callbacks::complex_error::UnexpectedErrorWithReason &e) {
21+
throw fixture_callbacks::complex_error::UnexpectedErrorWithReason(e.reason);
2022
} catch (const std::runtime_error &e) {
2123
throw fixture_callbacks::complex_error::UnexpectedErrorWithReason(e.what());
2224
}
@@ -28,7 +30,13 @@ std::vector<int32_t> fixture_callbacks::RustGetters::get_list(std::shared_ptr<fi
2830

2931
std::optional<std::string> fixture_callbacks::RustGetters::get_string_optional_callback(std::shared_ptr<fixture_callbacks::ForeignGetters> foreign, std::string v, bool argument_two) {
3032
if (foreign) {
31-
return foreign->get_string(v, argument_two);
33+
try {
34+
return foreign->get_string(v, argument_two);
35+
} catch (const fixture_callbacks::simple_error::BadArgument &e) {
36+
throw e;
37+
} catch (const std::runtime_error &e) {
38+
throw fixture_callbacks::simple_error::UnexpectedError();
39+
}
3240
}
3341

3442
return std::nullopt;

cpp-tests/scaffolding_tests/fixture_callbacks/lib_fixture_callbacks.hpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,13 @@ namespace {
1616
namespace simple_error {
1717
class BadArgument : public SimpleError {
1818
public:
19-
BadArgument() : SimpleError("") {}
19+
BadArgument() : SimpleError("BadArgument") {}
2020
BadArgument(const std::string &what_arg) : SimpleError(what_arg) {}
2121
};
2222

2323
class UnexpectedError : public SimpleError {
2424
public:
25-
UnexpectedError() : SimpleError("") {}
25+
UnexpectedError() : SimpleError("UnexpectedError") {}
2626
UnexpectedError(const std::string &what_arg) : SimpleError(what_arg) {}
2727
};
2828
}
@@ -36,15 +36,15 @@ namespace {
3636
namespace complex_error {
3737
class ReallyBadArgument : public ComplexError {
3838
public:
39-
ReallyBadArgument() : ComplexError("") {}
39+
ReallyBadArgument() : ComplexError("ReallyBadArgument") {}
4040
ReallyBadArgument(const std::string &what_arg) : ComplexError(what_arg) {}
4141

4242
uint32_t code;
4343
};
4444

4545
class UnexpectedErrorWithReason : public ComplexError {
4646
public:
47-
UnexpectedErrorWithReason() : ComplexError("") {}
47+
UnexpectedErrorWithReason() : ComplexError("InternalTelephoneError") {}
4848
UnexpectedErrorWithReason(const std::string &what_arg) : ComplexError(what_arg), reason(what_arg) {}
4949

5050
std::string reason;

0 commit comments

Comments
 (0)