CadQuery / CQ-editor

CadQuery GUI editor based on PyQT
Apache License 2.0
723 stars 111 forks source link

Long exceptions resize window #409

Open snoyer opened 11 months ago

snoyer commented 11 months ago

Exceptions with long messages will resize the "Current traceback" panel/widget, and, in turn, resize the whole application window.

Reproduction: raise ValueError("really "*64 + "long message")

cq-editor-before-exc cq-editor-after-exc

Now obviously this is a made up example and stuff like that never happens in real life, right?

Well... pick any OCC method with a few overloads and call it wrong with cq's OCP package, OCP will helpfully list the overloads on multiple line in the exception message.

from OCP.ShapeExtend import ShapeExtend_WireData
ShapeExtend_WireData().Add("blah")
Traceback (most recent call last):
  File "/tmp/err.py", line 2, in <module>
    ShapeExtend_WireData().Add("blah")
TypeError: Add(): incompatible function arguments. The following argument types are supported:
    1. (self: OCP.ShapeExtend.ShapeExtend_WireData, edge: OCP.TopoDS.TopoDS_Edge, atnum: int = 0) -> None
    2. (self: OCP.ShapeExtend.ShapeExtend_WireData, wire: OCP.TopoDS.TopoDS_Wire, atnum: int = 0) -> None
    3. (self: OCP.ShapeExtend.ShapeExtend_WireData, wire: OCP.ShapeExtend.ShapeExtend_WireData, atnum: int = 0) -> None
    4. (self: OCP.ShapeExtend.ShapeExtend_WireData, shape: OCP.TopoDS.TopoDS_Shape, atnum: int = 0) -> None

Invoked with: <OCP.ShapeExtend.ShapeExtend_WireData object at 0x7f083cb08cb0>, 'blah'

...all of which ends up a single looooooooooooooong line in cq-editor cq-editor-after-ocp-exc


Maybe there's some Qt options so the widget would clip the text instead of resizing itself? Or if that's not possible the message should be truncated at an arbitrary length before displaying?