Skip to content

Commit 97d4e32

Browse files
committed
general: use nassert_raise instead of nassertv(false) et al
Even a brief error message in the assertion is infinitely more useful to a user who is not at home in the source code, especially for assertions that may reasonably be triggered by honest user mistakes.
1 parent 594e6b3 commit 97d4e32

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+108
-79
lines changed

direct/src/dcparser/dcClass.cxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1240,7 +1240,7 @@ shadow_inherited_field(const string &name) {
12401240
}
12411241

12421242
// If we get here, the named field wasn't in the list. Huh.
1243-
nassertv(false);
1243+
nassert_raise("named field not in list");
12441244
}
12451245

12461246
/**

dtool/src/prc/notifyCategory.cxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ out(NotifySeverity severity, bool prefix) const {
110110
nout << *this << "(" << severity << "): ";
111111
}
112112
if (assert_abort) {
113-
nassertr(false, nout);
113+
nassert_raise("unprotected debug statement");
114114
}
115115

116116
return nout;

panda/src/chan/animChannelMatrixXfmTable.cxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ set_table(char table_id, const CPTA_stdfloat &table) {
239239
if (table.size() > 1 && (int)table.size() < num_frames) {
240240
// The new table has an invalid number of frames--it doesn't match the
241241
// bundle's requirement.
242-
nassertv(false);
242+
nassert_raise("mismatched number of frames");
243243
return;
244244
}
245245

panda/src/chan/animChannelScalarTable.cxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ set_table(const CPTA_stdfloat &table) {
104104
if (table.size() > 1 && (int)table.size() < num_frames) {
105105
// The new table has an invalid number of frames--it doesn't match the
106106
// bundle's requirement.
107-
nassertv(false);
107+
nassert_raise("mismatched number of frames");
108108
return;
109109
}
110110

panda/src/display/graphicsStateGuardian.cxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -743,7 +743,7 @@ issue_timer_query(int pstats_index) {
743743
*/
744744
void GraphicsStateGuardian::
745745
dispatch_compute(int num_groups_x, int num_groups_y, int num_groups_z) {
746-
nassertv(false /* Compute shaders not supported by GSG */);
746+
nassert_raise("Compute shaders not supported by GSG");
747747
}
748748

749749
/**

panda/src/egg/eggGroup.cxx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,8 @@ write(ostream &out, int indent_level) const {
192192

193193
default:
194194
// invalid group type
195-
nassertv(false);
195+
nassert_raise("invalid EggGroup type");
196+
return;
196197
}
197198

198199
if (is_of_type(EggBin::get_class_type())) {

panda/src/egg/eggVertexPool.cxx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -445,7 +445,8 @@ add_vertex(EggVertex *vertex, int index) {
445445
}
446446

447447
// Oops, you duplicated a vertex index.
448-
nassertr(false, nullptr);
448+
nassert_raise("duplicate vertex index");
449+
return nullptr;
449450
}
450451

451452
_unique_vertices.insert(vertex);

panda/src/egg/eggXfmAnimData.cxx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,8 @@ get_value(int row, LMatrix4d &mat) const {
142142

143143
default:
144144
// The contents string contained an invalid letter.
145-
nassertv(false);
145+
nassert_raise("invalid letter in contents string");
146+
return;
146147
}
147148
}
148149

panda/src/egg/eggXfmSAnim.cxx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,8 @@ get_value(int row, LMatrix4d &mat) const {
368368

369369
default:
370370
// One of the child tables had an invalid name.
371-
nassertv(false);
371+
nassert_raise("invalid name in child table");
372+
return;
372373
}
373374
}
374375
}

panda/src/event/asyncFuture.cxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,7 @@ wake_task(AsyncTask *task) {
298298
return;
299299

300300
default:
301-
nassertv(false);
301+
nassert_raise("unexpected task state");
302302
return;
303303
}
304304
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy