comparison src/org/tmatesoft/hg/repo/HgInvalidRevisionException.java @ 423:9c9c442b5f2e

Major refactoring of exception handling. Low-level API uses RuntimeExceptions, while checked are left for higher level
author Artem Tikhomirov <tikhomirov.artem@gmail.com>
date Fri, 23 Mar 2012 22:51:18 +0100
parents src/org/tmatesoft/hg/core/HgInvalidRevisionException.java@866fc3b597a0
children
comparison
equal deleted inserted replaced
422:5d1cc7366d04 423:9c9c442b5f2e
1 /*
2 * Copyright (c) 2011-2012 TMate Software Ltd
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; version 2 of the License.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * For information on how to redistribute this software under
14 * the terms of a license other than GNU General Public License
15 * contact TMate Software at support@hg4j.com
16 */
17 package org.tmatesoft.hg.repo;
18
19 import org.tmatesoft.hg.core.Nodeid;
20
21 /**
22 * Use of revision or revision local index that is not valid for a given revlog.
23 *
24 * @author Artem Tikhomirov
25 * @author TMate Software Ltd.
26 */
27 @SuppressWarnings("serial")
28 public class HgInvalidRevisionException extends HgRuntimeException {
29
30 /**
31 *
32 * This exception is not expected to be initialized with another exception, although those who need to,
33 * may still use {@link #initCause(Throwable)}
34 *
35 * @param message optional description of the issue
36 * @param revision invalid revision, may be <code>null</code> if revisionIndex is used
37 * @param revisionIndex invalid revision index, may be <code>null</code> if not known and revision is supplied
38 */
39 public HgInvalidRevisionException(String message, Nodeid revision, Integer revisionIndex) {
40 super(message, null);
41 assert revision != null || revisionIndex != null;
42 if (revision != null) {
43 setRevision(revision);
44 }
45 if (revisionIndex != null) {
46 setRevisionIndex(revisionIndex);
47 }
48 }
49
50 public HgInvalidRevisionException(Nodeid revision) {
51 this(null, revision, null);
52 }
53
54 public HgInvalidRevisionException(int revisionIndex) {
55 this(null, null, revisionIndex);
56 }
57
58 public HgInvalidRevisionException setRevisionIndex(int revisionIndex, int rangeLeft, int rangeRight) {
59 details.setRevisionIndexBoundary(revisionIndex, rangeLeft, rangeRight);
60 return this;
61 }
62 }