Menu

Scenario Log in to Edit

Arian Treffer

This page will show you an example how to use Java Snippet Search with a possible scenario.

Let's assume you find this in your code base. While printing the stack trace is not forbidden, some additional exception handling should occur.

try {
    doOperation();
} catch (OperationException e) {
    e.printStackTrace();
}

You are afraid that there are other places in the code where no proper exception handling is done, so you want a list of all occurrences of this pattern. Eclipse offers the feature to search for certain method invocations, but you cannot use that here, as it would also find snippets like this.

try {
    doOperation();
} catch (OperationException e) {
    e.printStackTrace(System.err);
    throw new InternalException(e);
}

Instead, you bring up the Snippet Search and enter the pattern that you want to find, or, as in this case, specify which patterns you don't want to find.

Snippet


Discussion

Anonymous
Anonymous

Add attachments
Cancel





MongoDB Logo MongoDB