Skip to content

Commit

Permalink
Anonymise error messages by removing exception handling
Browse files Browse the repository at this point in the history
Signed-off-by: Stephane Bouchet <[email protected]>
  • Loading branch information
sbouchet committed Jul 11, 2024
1 parent 4e36c83 commit 84dcc6a
Show file tree
Hide file tree
Showing 24 changed files with 86 additions and 102 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,7 @@ public void sendTelemetryResults(TelemetryService.TelemetryResult result) {

@Override
public void sendTelemetryError(String message) {
telemetrySender.sendTelemetryError(message);
telemetrySender.sendTelemetryError(message);
}

@Override
public void sendTelemetryError(Exception exception) {
telemetrySender.sendTelemetryError(exception);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,4 @@ public void sendTelemetryError(String message) {
telemetrySender.sendTelemetryError(message);
}

@Override
public void sendTelemetryError(Exception exception) {
telemetrySender.sendTelemetryError(exception);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public void actionPerformedOnSelectedObject(AnActionEvent anActionEvent, Object
NodeUtils.fireModified(node.getParent());
sendTelemetryResults(TelemetryService.TelemetryResult.SUCCESS);
} catch (IOException e) {
sendTelemetryError(e);
sendTelemetryError(e.getMessage());
Messages.showWarningDialog("Error: " + e.getLocalizedMessage(), "Delete Binding");
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public void actionPerformedOnSelectedObject(AnActionEvent anActionEvent, Object
odo.about();
sendTelemetryResults(TelemetryResult.SUCCESS);
} catch (IOException e) {
sendTelemetryError(e);
sendTelemetryError(e.getMessage());
UIHelper.executeInUI(() -> Messages.showErrorDialog("Error: " + e.getLocalizedMessage(), "About"));
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public void actionPerformedOnSelectedObject(AnActionEvent anActionEvent, Object
sendTelemetryResults(TelemetryResult.ABORTED);
}
} catch (IOException e) {
sendTelemetryError(e);
sendTelemetryError(e.getMessage());
UIHelper.executeInUI(() -> Messages.showErrorDialog("Error: " + e.getLocalizedMessage(), "Login"));
} finally {
clearProcessing(clusterNode);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public void actionPerformedOnSelectedObject(AnActionEvent anActionEvent, Object
BrowserUtil.open(url);
sendTelemetryResults(TelemetryResult.SUCCESS);
} catch (IOException e) {
sendTelemetryError(e);
sendTelemetryError(e.getMessage());
Messages.showErrorDialog("Error: " + e.getLocalizedMessage(), "Open Console Dashboard");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ private void doActionPerformed(NamespaceNode namespaceNode, Odo odo, Application
sendTelemetryResults(TelemetryResult.SUCCESS);
} catch (IOException e) {
clearProcessing(namespaceNode);
sendTelemetryError(e);
sendTelemetryError(e.getMessage());
UIHelper.executeInUI(() -> Messages.showErrorDialog("Error: " + e.getLocalizedMessage(), "Create Component"));
}
},
Expand All @@ -112,8 +112,8 @@ protected void createComponent(Odo odo, CreateComponentModel model)
computeTelemetry(model);
String type = model.getSelectedComponentType() != null ?
model.getSelectedComponentType().getName() : null;
String registry = model.getSelectedComponentType() instanceof DevfileComponentType ?
((DevfileComponentType) model.getSelectedComponentType()).getDevfileRegistry().getName() : null;
String registry = model.getSelectedComponentType() instanceof DevfileComponentType devfileComponentType ?
devfileComponentType.getDevfileRegistry().getName() : null;
String devFile = model.isProjectHasDevfile() ?
Constants.DEVFILE_NAME : null;
odo.createComponent(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ private void executeDebug() {
runSettings.getConfiguration())).execute(getEnvironment());
sendTelemetryResults(TelemetryResult.SUCCESS);
} catch (ExecutionException e) {
sendTelemetryError(e);
sendTelemetryError(e.getMessage());
LOG.error(e.getLocalizedMessage(), e);
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public void actionPerformedOnSelectedObject(AnActionEvent anActionEvent, Object
sendTelemetryResults(TelemetryResult.SUCCESS);
} catch (IOException e) {
clearProcessing(componentNode);
sendTelemetryError(e);
sendTelemetryError(e.getMessage());
UIHelper.executeInUI(() ->
Messages.showErrorDialog("Error: " + e.getLocalizedMessage(), "Delete Component"));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public void actionPerformedOnSelectedObject(AnActionEvent anActionEvent, Object
odo.describeComponent(component.getPath());
sendTelemetryResults(TelemetryResult.SUCCESS);
} catch (IOException e) {
sendTelemetryError(e);
sendTelemetryError(e.getMessage());
UIHelper.executeInUI(() -> Messages.showErrorDialog("Error: " + e.getLocalizedMessage(), "Describe"));
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ protected FeatureComponentAction(ComponentFeature feature) {
@Override
public boolean isVisible(Object selected) {
boolean visible = super.isVisible(selected);
if (visible && selected instanceof ComponentNode) {
Component component = ((ComponentNode) selected).getComponent();
if (visible && selected instanceof ComponentNode componentNode) {
Component component = componentNode.getComponent();
visible = component.getInfo().getSupportedFeatures().contains(feature.getMode());
}
return visible;
Expand All @@ -54,10 +54,9 @@ public void update(AnActionEvent e) {
super.update(e);
if (e.getPresentation().isVisible() && needCustomizedPresentation()) {
Object node = adjust(getSelected(getTree(e)));
if (!(node instanceof ComponentNode)) {
if (!(node instanceof ComponentNode componentNode)) {
return;
}
ComponentNode componentNode = (ComponentNode) node;
Component component = componentNode.getComponent();
e.getPresentation().setText(getCustomizedPresentation(component));
}
Expand Down Expand Up @@ -104,7 +103,7 @@ public void actionPerformedOnSelectedObject(AnActionEvent anActionEvent, Object
});
sendTelemetryResults(TelemetryResult.SUCCESS);
} catch (IOException e) {
sendTelemetryError(e);
sendTelemetryError(e.getMessage());
UIHelper.executeInUI(() -> Messages.showErrorDialog("Error: " + e.getLocalizedMessage(), getActionName()));
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public void actionPerformedOnSelectedObject(AnActionEvent anActionEvent, Object
clearProcessing(namespaceNode);
} catch (IOException e) {
clearProcessing(namespaceNode);
sendTelemetryError(e);
sendTelemetryError(e.getMessage());
UIHelper.executeInUI(() -> Messages.showErrorDialog("Error: " + e.getLocalizedMessage(), "Import"));
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@

import java.io.IOException;
import java.util.List;
import java.util.stream.Collectors;

import static org.jboss.tools.intellij.openshift.actions.ActionUtils.runWithProgress;
import static org.jboss.tools.intellij.openshift.actions.NodeUtils.clearProcessing;
Expand All @@ -46,7 +45,7 @@ protected String getSelectedTargetComponent(OdoFacade odo, String project, Strin
String targetComponent = null;

List<Component> components = odo.getComponents(project)
.stream().filter(comp -> !comp.getName().equals(component)).collect(Collectors.toList());
.stream().filter(comp -> !comp.getName().equals(component)).toList();
if (!components.isEmpty()) {
if (components.size() == 1) {
targetComponent = components.get(0).getName();
Expand Down Expand Up @@ -78,7 +77,7 @@ public void actionPerformedOnSelectedObject(AnActionEvent anActionEvent, Object
clearProcessing(namespaceNode);
} catch (IOException e) {
clearProcessing(namespaceNode);
sendTelemetryError(e);
sendTelemetryError(e.getMessage());
UIHelper.executeInUI(() -> Messages.showErrorDialog("Error: " + e.getLocalizedMessage(), "Link Component"));
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public void actionPerformedOnSelectedObject(AnActionEvent anActionEvent, Object
}
} catch (IOException | NoSuchElementException e) {
clearProcessing(namespaceNode);
sendTelemetryError(e);
sendTelemetryError(e.getMessage());
UIHelper.executeInUI(() -> Messages.showErrorDialog("Error: " + e.getLocalizedMessage(), "Link Service"));
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ protected void doLog(ComponentNode componentNode, OdoFacade odo, boolean follow)
}
sendTelemetryResults(TelemetryResult.SUCCESS);
} catch (IOException e) {
sendTelemetryError(e);
sendTelemetryError(e.getMessage());
UIHelper.executeInUI(() -> Messages.showErrorDialog("Error: " + e.getLocalizedMessage(), getActionName()));
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ private void createProject(String newProject, @NotNull Odo odo) {
sendTelemetryResults(TelemetryResult.SUCCESS);
} catch (IOException | CompletionException e) {
notification.expire();
sendTelemetryError(e);
sendTelemetryError(e.getMessage());
UIHelper.executeInUI(() -> Messages.showErrorDialog("Error: " + e.getLocalizedMessage(), "Create " + kind));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public void actionPerformedOnSelectedObject(AnActionEvent anActionEvent, Object
NodeUtils.fireRemoved(namespaceNode);
sendTelemetryResults(TelemetryResult.SUCCESS);
} catch (IOException e) {
sendTelemetryError(e);
sendTelemetryError(e.getMessage());
UIHelper.executeInUI(() -> Messages.showErrorDialog("Error: " + e.getLocalizedMessage(), "Delete " + kind));
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public void actionPerformedOnSelectedObject(AnActionEvent anActionEvent, Object
sendTelemetryResults(TelemetryResult.ABORTED);
}
} catch (IOException e) {
sendTelemetryError(e);
sendTelemetryError(e.getMessage());
Messages.showErrorDialog("Error: " + e.getLocalizedMessage(), "Create Registry");
}
}
Expand All @@ -63,7 +63,7 @@ private void createDevfileRegistry(AnActionEvent anActionEvent, CreateRegistryDi
ActionUtils.getApplicationTreeStructure(anActionEvent).fireModified(registriesNode);
sendTelemetryResults(TelemetryResult.SUCCESS);
} catch (IOException e) {
sendTelemetryError(e);
sendTelemetryError(e.getMessage());
UIHelper.executeInUI(() -> Messages.showErrorDialog("Error: " + e.getLocalizedMessage(),
"Create registry"));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public void actionPerformedOnSelectedObject(AnActionEvent anActionEvent, Object
NodeUtils.fireRemoved(registryNode);
sendTelemetryResults(TelemetryResult.SUCCESS);
} catch (IOException e) {
sendTelemetryError(e);
sendTelemetryError(e.getMessage());
UIHelper.executeInUI(() -> Messages.showErrorDialog("Error: " + e.getLocalizedMessage(), "Delete Registry"));
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public void actionPerformedOnSelectedObject(AnActionEvent anActionEvent, Object
sendTelemetryResults(TelemetryService.TelemetryResult.SUCCESS);
} catch (IOException e) {
clearProcessing(namespaceNode);
sendTelemetryError(e);
sendTelemetryError(e.getMessage());
UIHelper.executeInUI(() -> Messages.showErrorDialog("Error: " + e.getLocalizedMessage(), "Create Service"));
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public void actionPerformedOnSelectedObject(AnActionEvent anActionEvent, Object
sendTelemetryResults(TelemetryResult.SUCCESS);
} catch (IOException e) {
clearProcessing(serviceNode);
sendTelemetryError(e);
sendTelemetryError(e.getMessage());
UIHelper.executeInUI(() -> Messages.showErrorDialog("Error: " + e.getLocalizedMessage(), "Delete Service"));
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
import java.io.IOException;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

import static org.jboss.tools.intellij.openshift.actions.ActionUtils.runWithProgress;
import static org.jboss.tools.intellij.openshift.actions.NodeUtils.clearProcessing;
Expand Down Expand Up @@ -63,7 +62,7 @@ public void actionPerformedOnSelectedObject(AnActionEvent anActionEvent, Object
UIHelper.executeInUI(() -> Messages.showWarningDialog(message, "Link Component"));
}
} catch (IOException e) {
sendTelemetryError(e);
sendTelemetryError(e.getMessage());
UIHelper.executeInUI(() -> Messages.showErrorDialog("Error: " + e.getLocalizedMessage(), "Link Component"));
} finally {
clearProcessing(namespaceNode);
Expand Down Expand Up @@ -91,6 +90,6 @@ private Component getComponent(List<Component> components) {
}

private List<Component> getTargetComponents(OdoFacade odo, String project) throws IOException {
return odo.getComponents(project).stream().filter(component -> component.getLiveFeatures().isOnCluster()).collect(Collectors.toList());
return odo.getComponents(project).stream().filter(component -> component.getLiveFeatures().isOnCluster()).toList();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@

public interface TelemetryHandler {

void sendTelemetryResults(TelemetryResult result);
void sendTelemetryError(String message);
void sendTelemetryError(Exception exception);
void sendTelemetryResults(TelemetryResult result);

void sendTelemetryError(String message);

}
Loading

0 comments on commit 84dcc6a

Please sign in to comment.