tikhomirov@295: /*
tikhomirov@295: * Copyright (c) 2011 TMate Software Ltd
tikhomirov@295: *
tikhomirov@295: * This program is free software; you can redistribute it and/or modify
tikhomirov@295: * it under the terms of the GNU General Public License as published by
tikhomirov@295: * the Free Software Foundation; version 2 of the License.
tikhomirov@295: *
tikhomirov@295: * This program is distributed in the hope that it will be useful,
tikhomirov@295: * but WITHOUT ANY WARRANTY; without even the implied warranty of
tikhomirov@295: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
tikhomirov@295: * GNU General Public License for more details.
tikhomirov@295: *
tikhomirov@295: * For information on how to redistribute this software under
tikhomirov@295: * the terms of a license other than GNU General Public License
tikhomirov@295: * contact TMate Software at support@hg4j.com
tikhomirov@295: */
tikhomirov@295: package org.tmatesoft.hg.core;
tikhomirov@295:
tikhomirov@295: import java.io.File;
tikhomirov@295: import java.io.IOException;
tikhomirov@295:
tikhomirov@295: /**
tikhomirov@295: * Thrown when there are troubles working with local file. Most likely (but not necessarily) wraps IOException. Might be
tikhomirov@295: * perceived as specialized IOException with optional File and other repository information.
tikhomirov@295: *
tikhomirov@295: * Hg4J tries to minimize chances for IOException to occur (i.e. {@link File#canRead()} is checked before attempt to
tikhomirov@295: * read a file that might not exist, and doesn't use this exception to wrap each and any {@link IOException} source (e.g.
tikhomirov@295: * #close()
calls are unlikely to yield it), hence it is likely to address real cases when I/O error occurs.
tikhomirov@295: *
tikhomirov@295: * On the other hand, when a file is supposed to exist and be readable, this exception might get thrown as well to indicate
tikhomirov@295: * that's not true.
tikhomirov@295: *
tikhomirov@295: * @author Artem Tikhomirov
tikhomirov@295: * @author TMate Software Ltd.
tikhomirov@295: */
tikhomirov@295: @SuppressWarnings("serial")
tikhomirov@295: public class HgInvalidFileException extends HgException {
tikhomirov@295:
tikhomirov@295: private File localFile;
tikhomirov@295:
tikhomirov@295: public HgInvalidFileException(String message, Throwable th) {
tikhomirov@295: super(message, th);
tikhomirov@295: }
tikhomirov@295:
tikhomirov@295: public HgInvalidFileException(String message, Throwable th, File file) {
tikhomirov@295: super(message, th);
tikhomirov@295: localFile = file;
tikhomirov@295: }
tikhomirov@295:
tikhomirov@295: public HgInvalidFileException setFile(File file) {
tikhomirov@295: assert file != null;
tikhomirov@295: localFile = file;
tikhomirov@295: return this;
tikhomirov@295: }
tikhomirov@295:
tikhomirov@295: /**
tikhomirov@295: * @return file object that causes troubles, or null
if specific file is unknown
tikhomirov@295: */
tikhomirov@295: public File getFile() {
tikhomirov@295: return localFile;
tikhomirov@295: }
tikhomirov@295: }