Skip to content

Commit 28daa41

Browse files
committed
using xtd::helpers::throw_helper class
1 parent 6cb6092 commit 28daa41

16 files changed

+43
-28
lines changed

src/xtd.forms/src/xtd/forms/tool_bar.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -482,7 +482,7 @@ drawing::size tool_bar::default_size() const noexcept {
482482

483483
xtd::uptr<xtd::object> tool_bar::clone() const {
484484
auto result = xtd::new_uptr<tool_bar>(*this);
485-
if (typeof_(*result) != typeof_(*this)) xtd::helpers::throw_helper::throws(xtd::helpers::exception_case::invalid_cast, xtd::string::format("The {} does not implement clone method.", typeof_(*this).full_name()).c_str());
485+
if (typeof_(*result) != typeof_(*this)) throw_helper::throws(exception_case::invalid_cast, xtd::string::format("The {} does not implement clone method.", typeof_(*this).full_name()).c_str());
486486
return result;
487487
}
488488

src/xtd.forms/src/xtd/forms/tool_bar_button.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
using namespace xtd;
66
using namespace xtd::forms;
7+
using namespace xtd::helpers;
78

89
tool_bar_button::tool_bar_button() : data_(xtd::new_sptr<data>()) {
910
}
@@ -267,6 +268,6 @@ xtd::string tool_bar_button::to_string() const noexcept {
267268

268269
xtd::uptr<xtd::object> tool_bar_button::clone() const {
269270
auto result = xtd::new_uptr<tool_bar_button>(*this);
270-
if (typeof_(*result) != typeof_(*this)) xtd::helpers::throw_helper::throws(xtd::helpers::exception_case::invalid_cast, xtd::string::format("The {} does not implement clone method.", typeof_(*this).full_name()).c_str());
271+
if (typeof_(*result) != typeof_(*this)) throw_helper::throws(exception_case::invalid_cast, xtd::string::format("The {} does not implement clone method.", typeof_(*this).full_name()).c_str());
271272
return result;
272273
}

src/xtd.forms/src/xtd/forms/trace_form.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
using namespace xtd;
44
using namespace xtd::diagnostics;
55
using namespace xtd::forms;
6+
using namespace xtd::helpers;
67

78
trace_form::~trace_form() {
89
trace::listeners().erase(find(trace::listeners().begin(), trace::listeners().end(), listener_));
@@ -21,6 +22,6 @@ void trace_form::flush() {
2122

2223
xtd::uptr<xtd::object> trace_form::clone() const {
2324
auto result = xtd::new_uptr<trace_form>(*this);
24-
if (typeof_(*result) != typeof_(*this)) xtd::helpers::throw_helper::throws(xtd::helpers::exception_case::invalid_cast, xtd::string::format("The {} does not implement clone method.", typeof_(*this).full_name()).c_str());
25+
if (typeof_(*result) != typeof_(*this)) throw_helper::throws(exception_case::invalid_cast, xtd::string::format("The {} does not implement clone method.", typeof_(*this).full_name()).c_str());
2526
return result;
2627
}

src/xtd.forms/src/xtd/forms/track_bar.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
using namespace xtd;
1010
using namespace xtd::forms;
11+
using namespace xtd::helpers;
1112

1213
struct track_bar::data {
1314
int32 large_change = 5;
@@ -422,7 +423,7 @@ drawing::size track_bar::default_size() const noexcept {
422423

423424
xtd::uptr<xtd::object> track_bar::clone() const {
424425
auto result = xtd::new_uptr<track_bar>(*this);
425-
if (typeof_(*result) != typeof_(*this)) xtd::helpers::throw_helper::throws(xtd::helpers::exception_case::invalid_cast, xtd::string::format("The {} does not implement clone method.", typeof_(*this).full_name()).c_str());
426+
if (typeof_(*result) != typeof_(*this)) throw_helper::throws(exception_case::invalid_cast, xtd::string::format("The {} does not implement clone method.", typeof_(*this).full_name()).c_str());
426427
return result;
427428
}
428429

src/xtd.forms/src/xtd/forms/up_down_button.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
using namespace xtd;
1212
using namespace xtd::forms;
13+
using namespace xtd::helpers;
1314

1415
struct up_down_button::data {
1516
bool wrapped = false;
@@ -378,7 +379,7 @@ forms::create_params up_down_button::create_params() const noexcept {
378379

379380
xtd::uptr<xtd::object> up_down_button::clone() const {
380381
auto result = xtd::new_uptr<up_down_button>(*this);
381-
if (typeof_(*result) != typeof_(*this)) xtd::helpers::throw_helper::throws(xtd::helpers::exception_case::invalid_cast, xtd::string::format("The {} does not implement clone method.", typeof_(*this).full_name()).c_str());
382+
if (typeof_(*result) != typeof_(*this)) throw_helper::throws(exception_case::invalid_cast, xtd::string::format("The {} does not implement clone method.", typeof_(*this).full_name()).c_str());
382383
return result;
383384
}
384385

src/xtd.forms/src/xtd/forms/user_control.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
using namespace xtd;
1414
using namespace xtd::forms;
15+
using namespace xtd::helpers;
1516

1617
struct user_control::data {
1718
forms::border_sides border_sides = forms::border_sides::all;
@@ -133,7 +134,7 @@ forms::create_params user_control::create_params() const noexcept {
133134

134135
xtd::uptr<xtd::object> user_control::clone() const {
135136
auto result = xtd::new_uptr<user_control>(*this);
136-
if (typeof_(*result) != typeof_(*this)) xtd::helpers::throw_helper::throws(xtd::helpers::exception_case::invalid_cast, xtd::string::format("The {} does not implement clone method.", typeof_(*this).full_name()).c_str());
137+
if (typeof_(*result) != typeof_(*this)) throw_helper::throws(exception_case::invalid_cast, xtd::string::format("The {} does not implement clone method.", typeof_(*this).full_name()).c_str());
137138
return result;
138139
}
139140

src/xtd.forms/src/xtd/forms/v_scroll_bar.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
using namespace xtd;
88
using namespace xtd::drawing;
99
using namespace xtd::forms;
10+
using namespace xtd::helpers;
1011

1112
v_scroll_bar::v_scroll_bar() : scroll_bar(true) {
1213
/// @todo Delete the next line when the standard control is developed.
@@ -297,6 +298,6 @@ xtd::drawing::size v_scroll_bar::default_size() const noexcept {
297298

298299
xtd::uptr<xtd::object> v_scroll_bar::clone() const {
299300
auto result = xtd::new_uptr<v_scroll_bar>(*this);
300-
if (typeof_(*result) != typeof_(*this)) xtd::helpers::throw_helper::throws(xtd::helpers::exception_case::invalid_cast, xtd::string::format("The {} does not implement clone method.", typeof_(*this).full_name()).c_str());
301+
if (typeof_(*result) != typeof_(*this)) throw_helper::throws(exception_case::invalid_cast, xtd::string::format("The {} does not implement clone method.", typeof_(*this).full_name()).c_str());
301302
return result;
302303
}

src/xtd.forms/src/xtd/forms/vertical_layout_panel.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,21 @@
33

44
using namespace xtd;
55
using namespace xtd::forms;
6+
using namespace xtd::helpers;
67

78
const vertical_control_layout_style_collection& vertical_layout_panel::control_layout_styles() const noexcept {
89
return control_layout_styles_;
910
}
1011

1112
const vertical_control_layout_style& vertical_layout_panel::control_layout_style(const control_ref& control) const {
1213
auto it = std::find_if(control_layout_styles_.begin(), control_layout_styles_.end(), [&](auto item) {return item.first.get() == control;});
13-
if (it == control_layout_styles_.end()) xtd::helpers::throw_helper::throws(xtd::helpers::exception_case::argument);
14+
if (it == control_layout_styles_.end()) throw_helper::throws(exception_case::argument);
1415
return it->second;
1516
}
1617

1718
vertical_layout_panel& vertical_layout_panel::control_layout_style(const control_ref& control, const vertical_control_layout_style& value) {
1819
auto it = std::find_if(control_layout_styles_.begin(), control_layout_styles_.end(), [&](auto item) {return item.first.get() == control;});
19-
if (it == control_layout_styles_.end()) xtd::helpers::throw_helper::throws(xtd::helpers::exception_case::argument);
20+
if (it == control_layout_styles_.end()) throw_helper::throws(exception_case::argument);
2021
if (it->second != value) {
2122
it->second = value;
2223
perform_layout();
@@ -81,7 +82,7 @@ vertical_layout_panel vertical_layout_panel::create(const control& parent, const
8182

8283
xtd::uptr<xtd::object> vertical_layout_panel::clone() const {
8384
auto result = xtd::new_uptr<vertical_layout_panel>(*this);
84-
if (typeof_(*result) != typeof_(*this)) xtd::helpers::throw_helper::throws(xtd::helpers::exception_case::invalid_cast, xtd::string::format("The {} does not implement clone method.", typeof_(*this).full_name()).c_str());
85+
if (typeof_(*result) != typeof_(*this)) throw_helper::throws(exception_case::invalid_cast, xtd::string::format("The {} does not implement clone method.", typeof_(*this).full_name()).c_str());
8586
return result;
8687
}
8788

@@ -93,7 +94,7 @@ void vertical_layout_panel::on_control_added(const xtd::forms::control_event_arg
9394
void vertical_layout_panel::on_control_removed(const xtd::forms::control_event_args& e) {
9495
panel::on_control_removed(e);
9596
auto it = std::find_if(control_layout_styles_.begin(), control_layout_styles_.end(), [&](auto item) {return item.first.get() == e.control();});
96-
if (it == control_layout_styles_.end()) xtd::helpers::throw_helper::throws(xtd::helpers::exception_case::argument);
97+
if (it == control_layout_styles_.end()) throw_helper::throws(exception_case::argument);
9798
control_layout_styles_.erase(it);
9899
}
99100

@@ -131,7 +132,7 @@ void vertical_layout_panel::on_layout(const event_args& e) {
131132
if (layout_style.size_type() == size_type::absolute) height = static_cast<int32>(layout_style.height().value_or(control.get().default_size().height));
132133
else if (layout_style.size_type() == size_type::percent) height = static_cast<int32>(percent_height * (layout_style.height().value_or(0) / total_percent));
133134
else if (layout_style.size_type() == size_type::auto_size) height = static_cast<int32>(auto_size_height / auto_size_control_count);
134-
else xtd::helpers::throw_helper::throws(xtd::helpers::exception_case::argument);
135+
else throw_helper::throws(exception_case::argument);
135136
control.get().set_bounds(left, top, width, height);
136137
top += height + padding().bottom() + padding().top();
137138
}

src/xtd.tunit/src/xtd/tunit/test.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
using namespace xtd;
99
using namespace xtd::diagnostics;
10+
using namespace xtd::helpers;
1011
using namespace xtd::runtime::exception_services;
1112
using namespace xtd::tunit;
1213

@@ -80,17 +81,17 @@ const string& test::user_message() const noexcept {
8081
}
8182

8283
test& test::current_test() {
83-
if (!has_current_test()) xtd::helpers::throw_helper::throws(xtd::helpers::exception_case::null_pointer);
84+
if (!has_current_test()) throw_helper::throws(exception_case::null_pointer);
8485
return *current_test_;
8586
}
8687

8788
const test_class& test::current_test_class() {
88-
if (!has_current_test_class()) xtd::helpers::throw_helper::throws(xtd::helpers::exception_case::null_pointer);
89+
if (!has_current_test_class()) throw_helper::throws(exception_case::null_pointer);
8990
return *current_test_class_;
9091
}
9192

9293
const unit_test& test::current_unit_test() {
93-
if (!has_current_unit_test()) xtd::helpers::throw_helper::throws(xtd::helpers::exception_case::null_pointer);
94+
if (!has_current_unit_test()) throw_helper::throws(exception_case::null_pointer);
9495
return *current_unit_test_;
9596
}
9697

tests/xtd.core.unit_tests/src/xtd/tests/format_string_object_tests.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
#include <xtd/tunit/test_method_attribute>
66

77
using namespace xtd;
8+
using namespace xtd::helpers;
89
using namespace xtd::tunit;
910

1011
namespace {
@@ -24,14 +25,14 @@ namespace xtd {
2425
template<>
2526
std::string to_string(const point& p, const std::string& fmt, const std::locale& loc) {
2627
if (fmt.empty()) return format("({}, {})", p.x, p.y);
27-
if (fmt.size() > 1) xtd::helpers::throw_helper::throws(xtd::helpers::exception_case::format, "Format can contains only one character.");
28+
if (fmt.size() > 1) throw_helper::throws(exception_case::format, "Format can contains only one character.");
2829

2930
switch (fmt[0]) {
3031
case 'l': return format("(x={}, y={})", p.x, p.y);
3132
case 'L': return format("(X={}, Y={})", p.x, p.y);
3233
case 'g':
3334
case 'G': return format("({}, {})", p.x, p.y);
34-
default: xtd::helpers::throw_helper::throws(xtd::helpers::exception_case::format, "Format invalid argument.");
35+
default: throw_helper::throws(exception_case::format, "Format invalid argument.");
3536
}
3637
}
3738
}

0 commit comments

Comments
 (0)