BelfrySCAD / BOSL2

The Belfry OpenScad Library, v2.0. An OpenSCAD library of shapes, masks, and manipulators to make working with OpenSCAD easier. BETA
https://github.com/BelfrySCAD/BOSL2/wiki
BSD 2-Clause "Simplified" License
1.01k stars 115 forks source link

[BUG] regular_polyhedron_info "index set" query throws inappropriate error #1508

Closed MethylBromide closed 4 days ago

MethylBromide commented 6 days ago

Describe the bug A call to regular_polyhedron_info requesting the "index set" for a value of faces for which there are no known regular polyhedra, should return an empty set -- not throw an Assert error.

Code To Reproduce Bug

include <BOSL2/std.scad>
include <BOSL2/polyhedra.scad>
echo(regular_polyhedron_info(faces=21, info="index set"));

Expected behavior Expected something like: ECHO: [] to show that the result is the empty set. Instead I get:

Compiling design (CSG Tree generation)...
[ERROR: Assertion '(len(indexlist) > 0)' failed: "No polyhedra meet your specification" in file ../Program Files/OpenSCAD/libraries/BOSL2/polyhedra.scad, line 660](https://github.com/BelfrySCAD/BOSL2/issues/660,C:/Program%20Files/OpenSCAD/libraries/BOSL2/polyhedra.scad)
[TRACE: called by 'regular_polyhedron_info' in file , line 4](https://github.com/BelfrySCAD/BOSL2/issues/4,C:/3d)
[TRACE: called by 'echo' in file , line 4](https://github.com/BelfrySCAD/BOSL2/issues/4,C:/3d)

The file polyhedra.scad already contains all the knowledge about the properties of its supported polyhedra. It doesn't make sense to duplicate this information in the calling code to know which values of faces will cause emergency shutdown. This is not an actual emergency.

I mean, damn, I was just asking a question, you don't have to shoot me for it. If there are no matching polyhedra, I would like for my code to be able to decide how to recover from that gracefully -- not to have it decided for me. The abort is not appropriate.

Sure, I could put something in my code containing a list of the valid values that will not cause an error, and I guess that's what I'll have to do until this is fixed, but that's a maintainability problem. What if they add some new shapes to the library and now the library is no longer in sync with the calling code?

adrianVmariano commented 5 days ago

Seems reasonable.

adrianVmariano commented 4 days ago

This has been fixed by the latest PR.