Ignore:
Timestamp:
2008-07-24T15:01:34+12:00 (16 years ago)
Author:
oranfry
Message:

more specific error messages

File:
1 edited

Legend:

Unmodified
Added
Removed
  • release-kits/shared/ant-tasks/orans/RegexSearchReplace.java

    r16534 r16535  
    6060
    6161        } catch (IOException e) {
    62             throw new BuildException( "Error - Couldn't create the temp file" );
     62            throw new BuildException( "Error - Couldn't create or open the temp file" );
    6363        }
    6464
     
    6767        BufferedReader in = null;
    6868        try {
    69             in = new BufferedReader(new FileReader( file ));
     69            in = new BufferedReader( new FileReader( file ) );
    7070        } catch ( Exception e ) {
    7171            throw new BuildException( "Error - Couldn't open the specified file" );
     
    7474        //pass the file through, searching and replacing
    7575        String line;
    76         try {
    77             while ( (line = in.readLine()) != null ) {
     76        boolean hasMoreLines = true;
     77        while ( hasMoreLines ) {
     78
     79            try {
     80                line = in.readLine();
     81            } catch ( Exception e ) {
     82                throw new BuildException( "Error - Couldn't read from the specified file" );
     83            }
     84
     85            if ( line == null ) {
     86                hasMoreLines = false;
     87            } else {
    7888
    7989                String oldLine = line;
     
    8393                }
    8494
    85                 out.write(line);
    86                 out.newLine();
     95                try {
     96                    out.write(line);
     97                    out.newLine();
     98                } catch ( Exception e ) {
     99                    throw new BuildException( "Error - Couldn't write to the temp file" );
     100                }
    87101            }
    88         } catch ( Exception e ) {
    89             throw new BuildException( "Error - Couldn't read from the specified file" );
    90102        }
     103           
    91104
    92105        try {
    93 
    94106            //close them both up
    95107            in.close();
    96108            out.close();
    97 
    98109        } catch ( Exception e ) {
    99110            throw new BuildException( "Error - Couldn't close a file" );
Note: See TracChangeset for help on using the changeset viewer.