Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Raising a BoxExpressionError is not handled properly? #964

Closed
rocky opened this issue Jan 16, 2024 · 3 comments
Closed

Raising a BoxExpressionError is not handled properly? #964

rocky opened this issue Jan 16, 2024 · 3 comments

Comments

@rocky
Copy link
Member

rocky commented Jan 16, 2024

Description

A BoxExpressionError does not seem to be handled properly.

How to Reproduce

Evaluate in Django or mathicsscript

Graphics3D[Cylinder[0]]

Output Given

Traceback (most recent call last):
...
  File "Mathics3/mathics-core/mathics/builtin/box/expression.py", line 51, in __new__
    instance = super().__new__(cls, *elements, **kwargs)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "Mathics3/mathics-core/mathics/core/builtin.py", line 465, in __new__
    instance.init(*args, **kwargs)
  File 'Mathics3/mathics-core/mathics/builtin/box/graphics3d.py", line 602, in init
    raise BoxExpressionError
mathics.core.exceptions.BoxExpressionError

Expected behavior

Actually, I do not know what is expected. I know that an uncaught exception is not expected. In mathicsscript or mathics, this terminates the session.

Your Environment

All environments.

Additional context

Noticed in testing out things for a possible new release.

@rocky
Copy link
Member Author

rocky commented Jan 16, 2024

I can make a stab at addressing, but I am at a loss for what the right behavior is.

For Graphics3D[Sphere[1, 0, 1]] I have turned this into a Syntax error giving:

mathics.core.exceptions.BoxExpressionError: In Sphere[], expecting 2 elements: point(s) and radius, got 3.

but I don't know if this is right.

@mmatera
Copy link
Contributor

mmatera commented Jan 17, 2024

Ideally, the failing box expression should be replaced by a red rectangle in the picture, and showing an error message:
imagen

This can be done by catching the exception in line 233 of mathics/builtin/box/graphics3d.py

mmatera added a commit that referenced this issue Jan 19, 2024
Here we go with a proposal to address #964. The idea is that when an
invalid graphics primitive is processed, a pink rectangle is drawn
instead. Notice that in WMA no error message is shown in the client.
Just the pink background is shown in the image, plus a tooltip in the
notebook interface.
@rocky
Copy link
Member Author

rocky commented Jan 21, 2024

This issue handled, although the specific case Graphics3D[Cylinder[0]] is not. #970 is the follow on.

@rocky rocky closed this as completed Jan 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants