Skip to content

Commit

Permalink
Add exit on exception
Browse files Browse the repository at this point in the history
  • Loading branch information
Guy Davenport committed Oct 17, 2024
1 parent edf075a commit c22b7f0
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ plugins {
}

group = 'org.brapi'
version = '0.6.0-SNAPSHOT'
version = '0.7.0-SNAPSHOT'
sourceCompatibility = JavaVersion.VERSION_21
targetCompatibility = JavaVersion.VERSION_21

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public class BrAPICommand {
* Main method for application
* @param args arguments for application
*/
public static void main(String[] args) {
new CommandLine(new BrAPICommand()).execute(args);
public static void main(String... args) throws Exception {
System.exit(new CommandLine(new BrAPICommand()).execute(args));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,18 @@
import lombok.Getter;
import org.brapi.schematools.core.response.Response;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;

@Getter
public class BrAPICommandException extends RuntimeException {
Collection<Response.Error> allErrors ;
public BrAPICommandException(String message) {
super(message) ;

this.allErrors = new ArrayList<>() ;
}

public BrAPICommandException(String message, Collection<Response.Error> allErrors) {
super(message) ;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,9 @@ public void run() {
}
} catch (IOException exception) {
err.println(exception.getMessage());
if (throwExceptionOnFail) {
throw new BrAPICommandException(exception.getMessage()) ;
}
} finally {
if (out != null) {
out.close();
Expand Down

0 comments on commit c22b7f0

Please sign in to comment.