comparison src/org/tmatesoft/hg/core/HgInvalidFileException.java @ 295:981f9f50bb6c

Issue 11: Error log facility. SessionContext to share common facilities
author Artem Tikhomirov <tikhomirov.artem@gmail.com>
date Fri, 16 Sep 2011 05:35:32 +0200
parents
children 856517285256
comparison
equal deleted inserted replaced
294:32890bab7209 295:981f9f50bb6c
1 /*
2 * Copyright (c) 2011 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.core;
18
19 import java.io.File;
20 import java.io.IOException;
21
22 /**
23 * Thrown when there are troubles working with local file. Most likely (but not necessarily) wraps IOException. Might be
24 * perceived as specialized IOException with optional File and other repository information.
25 *
26 * <b>Hg4J</b> tries to minimize chances for IOException to occur (i.e. {@link File#canRead()} is checked before attempt to
27 * read a file that might not exist, and doesn't use this exception to wrap each and any {@link IOException} source (e.g.
28 * <code>#close()</code> calls are unlikely to yield it), hence it is likely to address real cases when I/O error occurs.
29 *
30 * On the other hand, when a file is supposed to exist and be readable, this exception might get thrown as well to indicate
31 * that's not true.
32 *
33 * @author Artem Tikhomirov
34 * @author TMate Software Ltd.
35 */
36 @SuppressWarnings("serial")
37 public class HgInvalidFileException extends HgException {
38
39 private File localFile;
40
41 public HgInvalidFileException(String message, Throwable th) {
42 super(message, th);
43 }
44
45 public HgInvalidFileException(String message, Throwable th, File file) {
46 super(message, th);
47 localFile = file;
48 }
49
50 public HgInvalidFileException setFile(File file) {
51 assert file != null;
52 localFile = file;
53 return this;
54 }
55
56 /**
57 * @return file object that causes troubles, or <code>null</code> if specific file is unknown
58 */
59 public File getFile() {
60 return localFile;
61 }
62 }