zalo / CascadeStudio

A Full Live-Scripted CAD Kernel in the Browser
https://zalo.github.io/CascadeStudio/
MIT License
1.01k stars 126 forks source link

CascadeStudio parameter sanity checking #37

Open udif opened 3 years ago

udif commented 3 years ago

It seems that CascadeStudio is not doing any sanity checking on parameters. As a result, a call such as:

Sphere(-10)

Will result in:

Line 75: Uncaught ReferenceError: ___cxa_is_pointer_type is not defined
Line 18: Uncaught There were no scene shapes returned!

When this is a part of a larger script, and the parameters are due to long calculations, it is very hard to debug the scripts. This is an example only, there are other unchecked calls.

brad commented 3 years ago

@udif As a workaround until something more robust is in place, you can simply log the computed radius (and anything else you want to debug) to the console using console.log commands

udif commented 3 years ago

Yes, I am making use of console.log() and alert().

zalo commented 3 years ago

Unfortunately, any errors that happen within the OpenCascade kernel are undebuggable due to the way it was compiled. :(

There's a PR for an Embind recompilation of OpenCascade (which should have better error reporting), but I haven't had a ton of time lately to work out all of the kinks in there, so it's been sitting in PR Queue hell since early October...

udif commented 3 years ago

What I implied by this issue was to add individual sanity checks in OpenCascade for each command before it is issued to the OpenCascade kernel library. The negative radius for Sphere() was an example.

In any case, the major issue I'm having is #38. If this was solved, there would be less need for issues such as this one (although it is pretty useful by itself).