comparison src/org/tmatesoft/hg/core/HgInvalidRevisionException.java @ 405:866fc3b597a0

Add an explicit constant instead of -1 to indicate 'no revision' case
author Artem Tikhomirov <tikhomirov.artem@gmail.com>
date Wed, 14 Mar 2012 22:49:32 +0100
parents 0ae53c32ecef
children
comparison
equal deleted inserted replaced
403:2747b0723867 405:866fc3b597a0
30 @Experimental(reason="1) Whether to use checked or runtime exception is not yet decided. 2) Perhaps, its use not bound to wrong arguments") 30 @Experimental(reason="1) Whether to use checked or runtime exception is not yet decided. 2) Perhaps, its use not bound to wrong arguments")
31 public class HgInvalidRevisionException extends IllegalArgumentException { 31 public class HgInvalidRevisionException extends IllegalArgumentException {
32 private Nodeid rev; 32 private Nodeid rev;
33 private Integer revIdx = BAD_REVISION; 33 private Integer revIdx = BAD_REVISION;
34 // next two make sense only when revIdx is present 34 // next two make sense only when revIdx is present
35 private int rangeLeftBoundary = -1, rangeRightBoundary = -1; 35 private int rangeLeftBoundary = BAD_REVISION, rangeRightBoundary = BAD_REVISION;
36 36
37 /** 37 /**
38 * 38 *
39 * this exception is not expected to be initialized with another exception, although those who need to, 39 * this exception is not expected to be initialized with another exception, although those who need to,
40 * may still use {@link #initCause(Throwable)} 40 * may still use {@link #initCause(Throwable)}
108 String sr; 108 String sr;
109 switch (revIdx) { 109 switch (revIdx) {
110 case BAD_REVISION : sr = "UNKNOWN"; break; 110 case BAD_REVISION : sr = "UNKNOWN"; break;
111 case TIP : sr = "TIP"; break; 111 case TIP : sr = "TIP"; break;
112 case WORKING_COPY: sr = "WORKING-COPY"; break; 112 case WORKING_COPY: sr = "WORKING-COPY"; break;
113 case NO_REVISION : sr = "NO REVISION"; break;
113 default : sr = revIdx.toString(); 114 default : sr = revIdx.toString();
114 } 115 }
115 if (rangeLeftBoundary != -1 || rangeRightBoundary != -1) { 116 if (rangeLeftBoundary != BAD_REVISION || rangeRightBoundary != BAD_REVISION) {
116 sb.append(String.format("%s is not from [%d..%d]", sr, rangeLeftBoundary, rangeRightBoundary)); 117 sb.append(String.format("%s is not from [%d..%d]", sr, rangeLeftBoundary, rangeRightBoundary));
117 } else { 118 } else {
118 sb.append(sr); 119 sb.append(sr);
119 } 120 }
120 } 121 }