Skip to content

Commit e877513

Browse files
committed
Fix some error messages
1 parent 9341c54 commit e877513

File tree

4 files changed

+11
-21
lines changed

4 files changed

+11
-21
lines changed

include/clasp/clbind/names.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,4 +49,4 @@ inline std::string PrepareName(const RawName& name) { return name._raw_name; }
4949
// eg: scope.def("foo<ThisIsATest>"_raw, ...)
5050
// ;; This will bind the symbol |foo<ThisIsATest>|
5151
//
52-
inline clbind::RawName operator"" _raw(const char* arg, size_t len) { return clbind::RawName(std::string(arg, len)); }
52+
inline clbind::RawName operator""_raw(const char* arg, size_t len) { return clbind::RawName(std::string(arg, len)); }

include/clasp/gctools/hardErrors.h

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,15 @@ class HardError {
4545
};
4646

4747
[[noreturn]] void throw_hard_error(const std::string& msg);
48+
49+
#define HARD_ERROR(msg) \
50+
throw_hard_error(fmt::format("{}:{}:{} {}\n", __FILE__, __LINE__, __FUNCTION__, msg))
51+
4852
[[noreturn]] void throw_hard_error_not_applicable_method(const char* msg);
4953
[[noreturn]] void throw_hard_error_bad_client(void* ptr);
5054
[[noreturn]] void throw_hard_error_bad_layout_command(int cmd);
5155
[[noreturn]] void throw_hard_error_side_stack_damaged(size_t totalSize, size_t calcSize);
5256
[[noreturn]] void throw_hard_error_mps_bad_result(int result);
53-
[[noreturn]] void throw_hard_error_failed_assertion(const char* assertion);
5457
[[noreturn]] void throw_hard_error_cast_failed(const char* type, const char* from);
5558
[[noreturn]] void throw_hard_error_cannot_cast_tagged_pointer(const char* name, size_t kind);
5659
[[noreturn]] void throw_hard_error_implement_me(const char* funcname, const char* filename, size_t lineno) noexcept(false);
@@ -87,12 +90,12 @@ class HardError {
8790
#define GCTOOLS_ASSERT(x) \
8891
{ \
8992
if (!(x)) \
90-
throw_hard_error_failed_assertion(#x); \
93+
HARD_ERROR("Failed assertion: " #x); \
9194
};
9295
#define GCTOOLS_ASSERTF(x, msg) \
9396
{ \
9497
if (!(x)) \
95-
throw_hard_error_failed_assertion(#x " " msg); \
98+
HARD_ERROR("Failed assertion: " #x " " msg); \
9699
};
97100
#else
98101
#define GCTOOLS_ASSERT(x)

include/clasp/gctools/smart_pointers.h

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -133,9 +133,7 @@ template <class T> class base_ptr {
133133

134134
template <class o_class> inline base_ptr<o_class> as_assert() const {
135135
#ifdef DEBUG_ASSERT
136-
if (!TaggedCast<o_class*, Type*>::isA(this->theObject)) {
137-
throw_hard_error_failed_assertion("as_assert failed!");
138-
}
136+
GCTOOLS_ASSERT(TaggedCast<o_class*, Type*>::isA(this->theObject))
139137
#endif
140138
base_ptr<o_class> ret((Tagged)this->theObject);
141139
return ret;
@@ -403,9 +401,7 @@ template <> class smart_ptr<core::T_O> {
403401

404402
template <class o_class> inline smart_ptr<o_class> as_assert() const {
405403
#ifdef DEBUG_ASSERT
406-
if (!TaggedCast<o_class*, Type*>::isA(this->theObject)) {
407-
throw_hard_error_failed_assertion("as_assert failed!");
408-
}
404+
GCTOOLS_ASSERT(TaggedCast<o_class*, Type*>::isA(this->theObject))
409405
#endif
410406
smart_ptr<o_class> ret((Tagged)this->theObject);
411407
return ret;
@@ -690,9 +686,7 @@ template <> class smart_ptr<core::Cons_O> {
690686
}
691687
template <class o_class> inline smart_ptr<o_class> as_assert() const {
692688
#ifdef DEBUG_ASSERT
693-
if (!TaggedCast<o_class*, Type*>::isA(this->theObject)) {
694-
throw_hard_error_failed_assertion("as_assert failed!");
695-
}
689+
GCTOOLS_ASSERT(TaggedCast<o_class*, Type*>::isA(this->theObject))
696690
#endif
697691
smart_ptr<o_class> ret((Tagged)this->theObject);
698692
return ret;
@@ -823,9 +817,7 @@ template <> class smart_ptr<core::List_V> {
823817
}
824818
template <class o_class> inline smart_ptr<o_class> as_assert() const {
825819
#ifdef DEBUG_ASSERT
826-
if (!TaggedCast<o_class*, Type*>::isA(this->theObject)) {
827-
throw_hard_error_failed_assertion("as_assert failed!");
828-
}
820+
GCTOOLS_ASSERT(TaggedCast<o_class*, Type*>::isA(this->theObject))
829821
#endif
830822
smart_ptr<o_class> ret((Tagged)this->theObject);
831823
return ret;

src/gctools/hardErrors.cc

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,6 @@
1717
abort();
1818
}
1919

20-
[[noreturn]] void throw_hard_error_failed_assertion(const char* assertion) {
21-
printf("%s:%d:%s %s\n", __FILE__, __LINE__, __FUNCTION__, assertion);
22-
abort();
23-
}
24-
2520
[[noreturn]] void throw_hard_error_not_applicable_method(const char* method) {
2621
printf("%s:%d:%s %s\n", __FILE__, __LINE__, __FUNCTION__, method);
2722
abort();

0 commit comments

Comments
 (0)