making use of "throw" information

EvanReese
EvanReese Member, Mentor Posts: 3,100 PRO

When using a function like createPath(), that will throw "Edges do not form a continuous path." if given disjointed inputs, how would I best kill the regeneration and tell the user what's wrong? I feel like there's probably a simple way I'm not aware of. I'm currently trying this, but it doesn't seem to run the catch statement because downstream things just say "Variable path not found".

try
{
var path = constructPath(context, definition.curves);
}
catch (error)
{
regenError("Curves do not form a continuous path", ["curves"], definition.curves);
}

Evan Reese
The Onsherpa | Reach peak Onshape productivity
www.theonsherpa.com

Answers

  • NeilCooke
    NeilCooke Moderator, Onshape Employees Posts: 6,126 image

    End the feature with a return?

    Senior Director, Technical Services, EMEA
  • EvanReese
    EvanReese Member, Mentor Posts: 3,100 PRO

    I've not used "return" mid feature like that. good tip. My issue was that I was missing "throw" before the regenError() function.

    Evan Reese
    The Onsherpa | Reach peak Onshape productivity
    www.theonsherpa.com