use of org.kie.workbench.common.stunner.core.diagram.DiagramParsingException in project kie-wb-common by kiegroup.
the class StunnerEditor method handleError.
public void handleError(final ClientRuntimeError error) {
final Throwable e = error.getThrowable();
if (e instanceof DiagramParsingException) {
final DiagramParsingException dpe = (DiagramParsingException) e;
close();
parsingExceptionProcessor.accept(dpe);
xmlEditorView = xmlEditorViews.get();
xmlEditorView.setReadOnly(isReadOnly());
xmlEditorView.setContent(dpe.getXml(), AceEditorMode.XML);
resetContentHash();
view.setWidget(xmlEditorView.asWidget());
Scheduler.get().scheduleDeferred(xmlEditorView::onResize);
} else {
String message = null;
if (e instanceof DefinitionNotFoundException) {
final DefinitionNotFoundException dnfe = (DefinitionNotFoundException) e;
message = translationService.getValue(CoreTranslationMessages.DIAGRAM_LOAD_FAIL_UNSUPPORTED_ELEMENTS, dnfe.getDefinitionId());
} else {
message = error.getThrowable() != null ? error.getThrowable().getMessage() : error.getMessage();
}
showError(message);
exceptionProcessor.accept(error.getThrowable());
}
}
use of org.kie.workbench.common.stunner.core.diagram.DiagramParsingException in project kie-wb-common by kiegroup.
the class StunnerEditorTest method testHandleParsingError.
@Test
@SuppressWarnings("all")
public void testHandleParsingError() {
Consumer<Throwable> exceptionConsumer = mock(Consumer.class);
tested.setExceptionProcessor(exceptionConsumer);
Consumer<DiagramParsingException> parsingExceptionConsumer = mock(Consumer.class);
tested.setParsingExceptionProcessor(parsingExceptionConsumer);
when(xmlEditorView.getContent()).thenReturn("testXml");
DiagramParsingException dpe = new DiagramParsingException(mock(Metadata.class), "testXml");
ClientRuntimeError error = new ClientRuntimeError(dpe);
tested.handleError(error);
verify(xmlEditorViews, times(1)).get();
verify(xmlEditorView, times(1)).setReadOnly(eq(false));
verify(xmlEditorView, times(1)).setContent(eq("testXml"), eq(AceEditorMode.XML));
verify(view, times(1)).setWidget(eq(xmlEditorViewWidget));
verify(errorPopupPresenter, never()).showMessage(anyString());
assertEquals("testXml".hashCode(), tested.getCurrentContentHash());
verify(parsingExceptionConsumer, times(1)).accept(eq(dpe));
verify(exceptionConsumer, never()).accept(any());
}
Aggregations