• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

incorrect command line parameters

 
Mike Hays
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey All,

What's the best way to handle errors cause by incorrect command line parameters? I was displaying a usage note in the console and exiting the application. I changed it to display a dialog with an error message describing the problem. In this case, the application exits after the dialog is dismissed. The problem with this is that there is no frame. If the dialog gets behind another window the user may not know that it is there.

 
Roel De Nijs
Sheriff
Posts: 10662
144
AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Mike,

I just wrote a message to System.err indicating the allowed command line parameters.

Kind regards,
Roel
 
Mike Hays
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
OK. What do you think about throwing an exception from main()? I'm considering throwing an IllegalArgumentException and not catching it in the main() method. A stack trace would appear in the console with the usage note. I wonder if this is not considered a good approach.

I don't think this is a big issue either way. Just trying to clean up some little things. Thanks.
 
Roel De Nijs
Sheriff
Posts: 10662
144
AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think the stack trace may confuse a user who is not so familiar with Java.
 
zhan dan
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
writing a message to System.err indicating the allowed command line parameters. That's a good way.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic