Welcome to the Onshape forum! Ask questions and join in the discussions about everything Onshape.

First time visiting? Here are some places to start:
  1. Looking for a certain topic? Check out the categories filter or use Search (upper right).
  2. Need support? Ask a question to our Community Support category.
  3. Please submit support tickets for bugs but you can request improvements in the Product Feedback category.
  4. Be respectful, on topic and if you see a problem, Flag it.

If you would like to contact our Community Manager personally, feel free to send a private message or an email.

How do I pass on "internal" errors to the user?

joshtargojoshtargo Member Posts: 446 EDU

For example, if they try something and it says this in the console, can I capture that error and post it as a reportFeatureWarning?

image.png

Also, the documentation is pretty bad for try/throw/catch (for a non programmer). what is the "e" catch (e)? What does throwing "e" do?

2025-08-31 16 42 17.png

Comments

  • MBartlett21MBartlett21 Member, OS Professional, Developers Posts: 2,063 ✭✭✭✭✭
    edited September 1

    e is a variable that holds whatever was thrown.

    Generally with throw regenError or similar, it is a map value with a message and some errorEntities.

    I've often used this in something like the below to make sure that errors come through to the user:

    try {
       [...]
    } catch (err) {
       if (err is map)
          throw err; // it will already present nicely
       else
          throw regenError(toString(err));
    }
    
    mb - draftsman - also FS author: View FeatureScripts
    IR for AS/NZS 1100
  • joshtargojoshtargo Member Posts: 446 EDU
  • Alex_KempenAlex_Kempen Member Posts: 255 EDU

    If you want the error directly, you can also use processSubfeatureStatus with propagateErrorDisplay set to true. This has the added benefit of giving you error bodies/highlighting from standard Onshape features (like a hole feature or a fillet). There is also callSubfeatureAndProcessStatus, which is just a more direct wrapper around processSubfeatureStatus.

    Software Developer at Epic Systems
    FRC Design Mentor - Team 1306 BadgerBots


  • joshtargojoshtargo Member Posts: 446 EDU

    incredible. this is great because the failed polyline or whatever stays visible and red, rather than disappearing. great!!

Sign In or Register to comment.