tikhomirov@423: /* tikhomirov@423: * Copyright (c) 2012 TMate Software Ltd tikhomirov@423: * tikhomirov@423: * This program is free software; you can redistribute it and/or modify tikhomirov@423: * it under the terms of the GNU General Public License as published by tikhomirov@423: * the Free Software Foundation; version 2 of the License. tikhomirov@423: * tikhomirov@423: * This program is distributed in the hope that it will be useful, tikhomirov@423: * but WITHOUT ANY WARRANTY; without even the implied warranty of tikhomirov@423: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the tikhomirov@423: * GNU General Public License for more details. tikhomirov@423: * tikhomirov@423: * For information on how to redistribute this software under tikhomirov@423: * the terms of a license other than GNU General Public License tikhomirov@423: * contact TMate Software at support@hg4j.com tikhomirov@423: */ tikhomirov@423: package org.tmatesoft.hg.repo; tikhomirov@423: tikhomirov@425: import org.tmatesoft.hg.core.HgException; tikhomirov@423: import org.tmatesoft.hg.core.Nodeid; tikhomirov@423: import org.tmatesoft.hg.internal.ExceptionInfo; tikhomirov@423: import org.tmatesoft.hg.util.Path; tikhomirov@423: tikhomirov@423: /** tikhomirov@425: * Almost any method in Hg4J low-level API (@link org.tmatesoft.hg.repo} may throw subclass of this exception tikhomirov@425: * to indicate unexpected state/condition encountered, flawed data or IO error. tikhomirov@425: * Since most cases can't be handled in a reasonable manner (other than catch all exceptions and tell client tikhomirov@425: * something went wrong), and propagating all possible exceptions up through API is dubious task, low-level tikhomirov@425: * exceptions are made runtime, rooting at this single class. tikhomirov@423: * tikhomirov@423: *
Hi-level api, {@link org.tmatesoft.hg.core}, where interaction with user-supplied values is more explicit,
tikhomirov@423: * may follow different exception strategy.
tikhomirov@423: *
tikhomirov@425: * @see HgException
tikhomirov@423: * @author Artem Tikhomirov
tikhomirov@423: * @author TMate Software Ltd.
tikhomirov@423: */
tikhomirov@423: @SuppressWarnings("serial")
tikhomirov@423: public abstract class HgRuntimeException extends RuntimeException {
tikhomirov@423:
tikhomirov@423: protected final ExceptionInfonull
when revision was supplied at construction time
tikhomirov@423: */
tikhomirov@423: public Nodeid getRevision() {
tikhomirov@423: return details.getRevision();
tikhomirov@423: }
tikhomirov@423:
tikhomirov@423: public HgRuntimeException setRevision(Nodeid r) {
tikhomirov@423: return details.setRevision(r);
tikhomirov@423: }
tikhomirov@423:
tikhomirov@423: public boolean isRevisionSet() {
tikhomirov@423: return details.isRevisionSet();
tikhomirov@423: }
tikhomirov@423:
tikhomirov@423: /**
tikhomirov@423: * @return non-null only if file name was set at construction time
tikhomirov@423: */
tikhomirov@423: public Path getFileName() {
tikhomirov@423: return details.getFileName();
tikhomirov@423: }
tikhomirov@423:
tikhomirov@423: public HgRuntimeException setFileName(Path name) {
tikhomirov@423: return details.setFileName(name);
tikhomirov@423: }
tikhomirov@423:
tikhomirov@423: @Override
tikhomirov@423: public String toString() {
tikhomirov@423: StringBuilder sb = new StringBuilder(super.toString());
tikhomirov@423: sb.append(' ');
tikhomirov@423: sb.append('(');
tikhomirov@423: details.appendDetails(sb);
tikhomirov@423: sb.append(')');
tikhomirov@423: return sb.toString();
tikhomirov@423: }
tikhomirov@423: }