Skip to content

NullPointerException in case of SVG load error

Simulating the following .chi file:

model M():
  file f = open("SVG:does_not_exist.svg", "w");
  close(f);
end

results in:

ERROR: Invalid input was encountered.
CAUSE: Failed to open editor "org.eclipse.escet.common.svg.SvgVisualizer" for file "C:\Programs\Siemens\escet\dev121-2\runtime-product-escet\test\does_not_exist.svg".
CAUSE: (NullPointerException) <cause details not available>

The following is logged:

java.lang.NullPointerException
	at org.eclipse.escet.common.svg.SvgViewer.createContents(SvgViewer.java:322)
	at org.eclipse.escet.common.eclipse.ui.ControlEditor.createPartControl(ControlEditor.java:123)
[...]

The SvgViewer crashes with a NullPointerException if the SVG file could not be loaded, rather than opening and then displaying the error in the visualizer, and forwarding it to the simulator. The expected simulation result is:

ERROR: Failed to load SVG image "[...]\test\does_not_exist.svg".
CAUSE: SVG image file "[...]\test\does_not_exist.svg" could not be found, is a directory, or for some other reason could not be opened for reading.
CAUSE: (FileNotFoundException) [...]\test\does_not_exist.svg (The system cannot find the file specified)