Skip to content

Commit

Permalink
Update example for SystemExitOutsideMain to more accurately describe …
Browse files Browse the repository at this point in the history
…the problem

PiperOrigin-RevId: 443731509
  • Loading branch information
nick-someone authored and Error Prone Team committed Apr 22, 2022
1 parent 5bd42a2 commit 1e1ddd8
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions docs/bugpattern/SystemExitOutsideMain.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,17 @@ For example, prefer this:
```java
public static void main(String[] args) {
try {
doSomething(args);
doSomething(args[0]);
} catch (MyUncheckedException e) {
System.err.println(e.getMessage());
System.exit(1);
}
}

private static void doSomething(args) {
// In library code
public static void doSomething(String s) {
try {
doSomethingElse(...);
doSomethingElse(s);
} catch (MyCheckedException e) {
throw new MyUncheckedException(e);
}
Expand All @@ -30,8 +31,13 @@ to this:

```java
public static void main(String[] args) {
doSomething(args[0]);
}

// In library code
public static void doSomething(String s) {
try {
doSomething(...);
doSomethingElse(s)
} catch (MyCheckedException e) {
System.err.println(e.getMessage());
System.exit(1);
Expand Down

0 comments on commit 1e1ddd8

Please sign in to comment.