From 703d6a8859df69dbde44a5b97254e300405a2d44 Mon Sep 17 00:00:00 2001 From: Adrian Schlatter <10478149+adrianschlatter@users.noreply.github.com> Date: Tue, 9 Jun 2020 18:07:21 +0200 Subject: [PATCH] thread_specs(...): Error Msg Added helpful error message if thread_specs(...) is unable to look up designator. Compare PR #36. closes #37 --- threadlib.scad | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/threadlib.scad b/threadlib.scad index 8f9e2ea..132efb5 100644 --- a/threadlib.scad +++ b/threadlib.scad @@ -17,9 +17,12 @@ include function thread_specs(designator, table=THREAD_TABLE) = /* Returns thread specs of thread-type 'designator' as a vector of [pitch, Rrotation, Dsupport, section_profile] */ - - table[search([designator], table, num_returns_per_match=1, - index_col_num=0)[0]][1]; + + // first lookup designator in table inside a let() statement: + let (specs = table[search([designator], table, num_returns_per_match=1, + index_col_num=0)[0]][1]) + // verify that we found something and return it: + assert(!is_undef(specs), str("Designator: '", designator, "' not found")) specs; module thread(designator, turns, higbee_arc=20, fn=120, table=THREAD_TABLE) {