comparison src/org/tmatesoft/hg/core/HgInvalidFileException.java @ 403:2747b0723867

FIXMEs: work on exceptions and javadoc
author Artem Tikhomirov <tikhomirov.artem@gmail.com>
date Mon, 05 Mar 2012 14:50:51 +0100
parents 0ae53c32ecef
children
comparison
equal deleted inserted replaced
402:1fcc7f7b6d65 403:2747b0723867
34 * @author TMate Software Ltd. 34 * @author TMate Software Ltd.
35 */ 35 */
36 @SuppressWarnings("serial") 36 @SuppressWarnings("serial")
37 public class HgInvalidFileException extends HgException { 37 public class HgInvalidFileException extends HgException {
38 38
39 private File localFile;
40
41 public HgInvalidFileException(String message, Throwable th) { 39 public HgInvalidFileException(String message, Throwable th) {
42 super(message, th); 40 super(message, th);
43 } 41 }
44 42
45 public HgInvalidFileException(String message, Throwable th, File file) { 43 public HgInvalidFileException(String message, Throwable th, File file) {
46 super(message, th); 44 super(message, th);
47 localFile = file; // allows null 45 extras.setFile(file); // allows null
48 } 46 }
49 47
50 public HgInvalidFileException setFile(File file) { 48 public HgInvalidFileException setFile(File file) {
51 assert file != null; // doesn't allow null not to clear file accidentally 49 assert file != null; // doesn't allow null not to clear file accidentally
52 localFile = file; 50 extras.setFile(file);
53 return this; 51 return this;
54 } 52 }
55 53
56 /** 54 /**
57 * @return file object that causes troubles, or <code>null</code> if specific file is unknown 55 * @return file object that causes troubles, or <code>null</code> if specific file is unknown
58 */ 56 */
59 public File getFile() { 57 public File getFile() {
60 return localFile; 58 return extras.getFile();
61 }
62
63 @Override
64 protected void appendDetails(StringBuilder sb) {
65 super.appendDetails(sb);
66 if (localFile != null) {
67 sb.append(';');
68 sb.append(' ');
69 sb.append(" file:");
70 sb.append(localFile.getPath());
71 sb.append(',');
72 if (localFile.exists()) {
73 sb.append("EXISTS");
74 } else {
75 sb.append("DOESN'T EXIST");
76 }
77 }
78 } 59 }
79 } 60 }