Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.help > #594
| From | markspace <-@.> |
|---|---|
| Newsgroups | comp.lang.java.help |
| Subject | Re: Good practice or not to close the file before System.exit(1)? |
| Date | 2011-04-22 15:24 -0700 |
| Organization | A noiseless patient Spider |
| Message-ID | <iosv7m$ogl$1@dont-email.me> (permalink) |
| References | <87mxjjqmlf.fsf@merciadriluca-station.MERCIADRILUCA> <87ipu67b41.fsf@merciadriluca-station.MERCIADRILUCA> <ios6c3$dpq$1@dont-email.me> <MMidna2aTZaJOizQnZ2dnUVZ_r2dnZ2d@earthlink.com> <System-exit-20110422182803@ram.dialup.fu-berlin.de> |
On 4/22/2011 9:31 AM, Stefan Ram wrote:
> Patricia Shanahan<pats@acm.org> writes:
>> To take the extreme case of high level code, what is the main
>> method of an application supposed to do when, through
>> exceptions or otherwise, it finds out that the program should
>> terminate with status code 1?
>
> (I already answered this before in one of my posts in this thread.)
>
> One single call of »System.exit« is justified for this purpose at
> the very end of »main«:
This is what I was thinking too. One way to implement this would be to
add some sort of extra value to Exceptions to allow lower level code to
pass up an exit status (note: this is getting way beyond what the OP
should care about, I'm just extending the idea of an exit status here to
include exceptions):
public interface ExceptionStatus {
int getExitStatus();
}
...
public class Main {
public static void main( String[] args ) {
try {
// ...whole program...
} catch( Throwable t ) {
// ...preform final processing... then:
if( t instanceof ExceptionStatus ) {
int status = ((ExceptionStatus)t).getExitStatus();
System.exit( status );
}
}
}
Back to comp.lang.java.help | Previous | Next — Previous in thread | Next in thread | Find similar
Good practice or not to close the file before System.exit(1)? Merciadri Luca <Luca.Merciadri@student.ulg.ac.be> - 2011-04-22 00:13 +0200
Re: Good practice or not to close the file before System.exit(1)? rossum <rossum48@coldmail.com> - 2011-04-22 00:11 +0100
Re: Good practice or not to close the file before System.exit(1)? rossum <rossum48@coldmail.com> - 2011-04-22 12:39 +0100
Re: Good practice or not to close the file before System.exit(1)? Patricia Shanahan <pats@acm.org> - 2011-04-22 05:09 -0700
Re: Good practice or not to close the file before System.exit(1)? Lew <noone@lewscanon.com> - 2011-04-22 09:39 -0400
Re: Good practice or not to close the file before System.exit(1)? Merciadri Luca <Luca.Merciadri@student.ulg.ac.be> - 2011-04-23 13:20 +0200
Re: Good practice or not to close the file before System.exit(1)? Merciadri Luca <Luca.Merciadri@student.ulg.ac.be> - 2011-04-22 16:37 +0200
Re: Good practice or not to close the file before System.exit(1)? Patricia Shanahan <pats@acm.org> - 2011-04-22 04:55 -0700
Re: Good practice or not to close the file before System.exit(1)? Merciadri Luca <Luca.Merciadri@student.ulg.ac.be> - 2011-04-22 13:56 +0200
Re: Good practice or not to close the file before System.exit(1)? Arved Sandstrom <asandstrom3minus1@eastlink.ca> - 2011-04-22 09:36 -0300
Re: Good practice or not to close the file before System.exit(1)? markspace <-@.> - 2011-04-22 08:20 -0700
Re: Good practice or not to close the file before System.exit(1)? Patricia Shanahan <pats@acm.org> - 2011-04-22 09:04 -0700
Re: Good practice or not to close the file before System.exit(1)? markspace <-@.> - 2011-04-22 15:24 -0700
Re: Good practice or not to close the file before System.exit(1)? markspace <-@.> - 2011-04-22 18:11 -0700
Re: Good practice or not to close the file before System.exit(1)? markspace <-@.> - 2011-04-23 08:25 -0700
Re: Good practice or not to close the file before System.exit(1)? Merciadri Luca <Luca.Merciadri@student.ulg.ac.be> - 2011-04-22 18:55 +0200
Re: Good practice or not to close the file before System.exit(1)? Lew <noone@lewscanon.com> - 2011-04-22 13:40 -0400
Re: Good practice or not to close the file before System.exit(1)? Patricia Shanahan <pats@acm.org> - 2011-04-22 10:55 -0700
Re: Good practice or not to close the file before System.exit(1)? Merciadri Luca <Luca.Merciadri@student.ulg.ac.be> - 2011-04-22 22:58 +0200
Re: Good practice or not to close the file before System.exit(1)? Merciadri Luca <Luca.Merciadri@student.ulg.ac.be> - 2011-04-22 23:09 +0200
Re: Good practice or not to close the file before System.exit(1)? Patricia Shanahan <pats@acm.org> - 2011-04-22 14:30 -0700
Re: Good practice or not to close the file before System.exit(1)? markspace <-@.> - 2011-04-22 15:38 -0700
Re: Good practice or not to close the file before System.exit(1)? Patricia Shanahan <pats@acm.org> - 2011-04-22 17:00 -0700
Re: Good practice or not to close the file before System.exit(1)? Lew <noone@lewscanon.com> - 2011-04-22 22:10 -0400
Re: Good practice or not to close the file before System.exit(1)? Patricia Shanahan <pats@acm.org> - 2011-04-22 19:46 -0700
Re: Good practice or not to close the file before System.exit(1)? Lew <noone@lewscanon.com> - 2011-04-23 09:54 -0400
Re: Good practice or not to close the file before System.exit(1)? Roedy Green <see_website@mindprod.com.invalid> - 2011-04-22 12:45 -0700
Re: Good practice or not to close the file before System.exit(1)? Merciadri Luca <Luca.Merciadri@student.ulg.ac.be> - 2011-04-22 23:20 +0200
csiph-web