Добавлен обработчик try/catch

This commit is contained in:
Victor 2013-12-02 15:30:46 +02:00
parent 72b797de7c
commit 9569b311b0
8 changed files with 29 additions and 18 deletions

View File

@ -9,6 +9,7 @@ import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.nio.channels.FileChannel;
import tse.Util;
/**
*
@ -39,7 +40,7 @@ public class DirCopy extends AbstractFileChooser {
new OutputStreamWriter(new FileOutputStream(logFile, true), "UTF-8")
);
} catch (IOException ex) {
ex.printStackTrace();
Util.handleException(ex);
}
}
@ -56,7 +57,7 @@ public class DirCopy extends AbstractFileChooser {
copyFile(file, dirDest);
writeLog(file.getAbsolutePath());
} catch (IOException ex) {
ex.printStackTrace();
Util.handleException(ex);
}
}
} else writeLog("Нечего копировать из " + dirSource.getAbsolutePath());
@ -97,7 +98,9 @@ public class DirCopy extends AbstractFileChooser {
try {
writer.write(filename);
writer.newLine();
} catch (IOException ex) { }
} catch (IOException ex) {
Util.handleException(ex);
}
}
private final FileFilter lastModifiedFilter = new FileFilter() {

View File

@ -13,6 +13,7 @@ import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import tse.Util;
/**
*
@ -43,7 +44,7 @@ public class DirFindText extends AbstractFileChooser {
new OutputStreamWriter(new FileOutputStream(logFile, true), "UTF-8")
);
} catch (IOException ex) {
ex.printStackTrace();
Util.handleException(ex);
}
}
@ -69,7 +70,9 @@ public class DirFindText extends AbstractFileChooser {
// Ищем строку в файле
try {
findString(file, SEARCH_TEXT);
} catch (IOException ex) {}
} catch (IOException ex) {
Util.handleException(ex);
}
}
}
}
@ -105,7 +108,9 @@ public class DirFindText extends AbstractFileChooser {
try {
writer.write(filename);
writer.newLine();
} catch (IOException ex) { }
} catch (IOException ex) {
Util.handleException(ex);
}
}
private class FindInfo {

View File

@ -8,6 +8,7 @@ import java.io.IOException;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;
import java.util.zip.ZipOutputStream;
import tse.Util;
/**
*
@ -48,7 +49,7 @@ public class DirZip extends AbstractFileChooser {
zos.close();
}
} catch (IOException ex) {
ex.printStackTrace();
Util.handleException(ex);
}
System.out.println("Готово!");
}

View File

@ -13,6 +13,7 @@ import java.io.ObjectOutputStream;
import java.io.OutputStreamWriter;
import java.util.ArrayList;
import java.util.List;
import tse.Util;
/**
*
@ -79,7 +80,7 @@ public class LR_3_Tasks {
printList(ellipses);
System.out.println("Готово");
} catch (IOException ex) {
ex.printStackTrace();
Util.handleException(ex);
}
}
@ -106,7 +107,7 @@ public class LR_3_Tasks {
oos.close();
fos.close();
} catch (IOException ex) {
ex.printStackTrace();
Util.handleException(ex);
}
}
@ -119,7 +120,7 @@ public class LR_3_Tasks {
ois.close();
fis.close();
} catch (IOException | ClassNotFoundException ex) {
ex.printStackTrace();
Util.handleException(ex);
}
return object;
}

View File

@ -6,6 +6,7 @@ import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.util.ArrayList;
import tse.Util;
/**
* Менеджер аккаунтов.
@ -67,7 +68,7 @@ public class AccountManager {
oos.close();
fos.close();
} catch (IOException ex) {
ex.printStackTrace();
Util.handleException(ex);
}
}
@ -80,7 +81,7 @@ public class AccountManager {
ois.close();
fis.close();
} catch (IOException | ClassNotFoundException ex) {
ex.printStackTrace();
Util.handleException(ex);
}
return object;
}

View File

@ -11,6 +11,7 @@ import java.text.ParseException;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import tse.Util;
/**
* Менеджер записей ежедневника.
@ -79,7 +80,7 @@ public class NotePadManager {
writer.flush();
writer.close();
} catch (IOException ex) {
ex.printStackTrace();
Util.handleException(ex);
}
}
@ -103,7 +104,7 @@ public class NotePadManager {
reader.close();
return list;
} catch (IOException ex) {
ex.printStackTrace();
Util.handleException(ex);
}
return null;
}

View File

@ -7,6 +7,7 @@ import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;
import tse.Util;
/**
* Чтение CSV файла.
@ -63,7 +64,7 @@ public class CsvReader<T> {
obj = (T) handler.createObject(params);
}
} catch (RuntimeException ex) {
ex.printStackTrace();
Util.handleException(ex);
}
if (obj != null) list.add(obj);
}
@ -71,6 +72,4 @@ public class CsvReader<T> {
handler.onFinishRead(file);
return list;
}
}

View File

@ -66,7 +66,7 @@ public class TrianglesWindow extends JFrame {
try {
csvReader.readCsv();
} catch (IOException ex) {
ex.printStackTrace();
Util.handleException(ex);
}
}