Mercurial > jhg
comparison src/org/tmatesoft/hg/core/HgException.java @ 275:6d1804fe0ed7
Issue 10: Report file content length with respect of metadata. Respect dirstate parents for WC's status. Exceptions to keep useful attributes of the location
author | Artem Tikhomirov <tikhomirov.artem@gmail.com> |
---|---|
date | Thu, 25 Aug 2011 21:35:03 +0200 |
parents | 1a7a9a20e1f9 |
children | 678e326fd27c |
comparison
equal
deleted
inserted
replaced
274:9fb50c04f03c | 275:6d1804fe0ed7 |
---|---|
14 * the terms of a license other than GNU General Public License | 14 * the terms of a license other than GNU General Public License |
15 * contact TMate Software at support@hg4j.com | 15 * contact TMate Software at support@hg4j.com |
16 */ | 16 */ |
17 package org.tmatesoft.hg.core; | 17 package org.tmatesoft.hg.core; |
18 | 18 |
19 import static org.tmatesoft.hg.repo.HgRepository.BAD_REVISION; | |
20 | |
21 import org.tmatesoft.hg.repo.HgRepository; | |
22 import org.tmatesoft.hg.util.Path; | |
23 | |
19 /** | 24 /** |
20 * Root class for all hg4j exceptions. | 25 * Root class for all hg4j exceptions. |
21 * | 26 * |
22 * @author Artem Tikhomirov | 27 * @author Artem Tikhomirov |
23 * @author TMate Software Ltd. | 28 * @author TMate Software Ltd. |
24 */ | 29 */ |
25 @SuppressWarnings("serial") | 30 @SuppressWarnings("serial") |
26 public class HgException extends Exception { | 31 public class HgException extends Exception { |
32 | |
33 protected int revNumber = BAD_REVISION; | |
34 protected Nodeid revision; | |
35 protected Path filename; | |
27 | 36 |
28 public HgException(String reason) { | 37 public HgException(String reason) { |
29 super(reason); | 38 super(reason); |
30 } | 39 } |
31 | 40 |
35 | 44 |
36 public HgException(Throwable cause) { | 45 public HgException(Throwable cause) { |
37 super(cause); | 46 super(cause); |
38 } | 47 } |
39 | 48 |
49 /** | |
50 * @return not {@link HgRepository#BAD_REVISION} only when local revision number was supplied at the construction time | |
51 */ | |
52 public int getRevisionNumber() { | |
53 return revNumber; | |
54 } | |
55 | |
56 public HgException setRevisionNumber(int rev) { | |
57 revNumber = rev; | |
58 return this; | |
59 } | |
60 | |
61 /** | |
62 * @return non-null only when revision was supplied at construction time | |
63 */ | |
64 public Nodeid getRevision() { | |
65 return revision; | |
66 } | |
67 | |
68 public HgException setRevision(Nodeid r) { | |
69 revision = r; | |
70 return this; | |
71 } | |
72 | |
73 /** | |
74 * @return non-null only if file name was set at construction time | |
75 */ | |
76 public Path getFileName() { | |
77 return filename; | |
78 } | |
79 | |
80 public HgException setFileName(Path name) { | |
81 filename = name; | |
82 return this; | |
83 } | |
84 | |
85 protected void appendDetails(StringBuilder sb) { | |
86 if (filename != null) { | |
87 sb.append(filename); | |
88 sb.append(':'); | |
89 sb.append(' '); | |
90 } | |
91 if (revNumber != BAD_REVISION) { | |
92 sb.append(revNumber); | |
93 if (revision != null) { | |
94 sb.append(':'); | |
95 } | |
96 } | |
97 if (revision != null) { | |
98 sb.append(revision.shortNotation()); | |
99 } | |
100 } | |
101 | |
40 // /* XXX CONSIDER capability to pass extra information about errors */ | 102 // /* XXX CONSIDER capability to pass extra information about errors */ |
41 // public static class Status { | 103 // public static class Status { |
42 // public Status(String message, Throwable cause, int errorCode, Object extraData) { | 104 // public Status(String message, Throwable cause, int errorCode, Object extraData) { |
43 // } | 105 // } |
44 // } | 106 // } |