Allow setting detail message and cause when constructing most exceptions

In particular, this means a RepositoryResolver, UploadPackFactory, or
ReceivePackFactory can set a detail message for
ServiceNotAuthorizedException or ServiceNotEnabledException with
information for the client about why access is not allowed.

Change-Id: I38e1798e1e9d09b5e75cefacd9d85f25729235a9
Signed-off-by: Jonathan Nieder <jrn@google.com>
This commit is contained in:
Jonathan Nieder 2015-06-02 16:52:21 -07:00
parent cc4f4f2fe1
commit 8c3fe215b4
7 changed files with 96 additions and 0 deletions

View File

@ -43,6 +43,15 @@
public class RefNotFoundException extends GitAPIException {
private static final long serialVersionUID = 1L;
/**
* @param message
* @param cause
* @since 4.1
*/
public RefNotFoundException(String message, Throwable cause) {
super(message, cause);
}
/**
* @param message
*/

View File

@ -9,6 +9,15 @@ public class StashApplyFailureException extends GitAPIException {
private static final long serialVersionUID = 1L;
/**
* @param message
* @param cause
* @since 4.1
*/
public StashApplyFailureException(String message, Throwable cause) {
super(message, cause);
}
/**
* Create a StashApplyFailedException
*

View File

@ -61,4 +61,13 @@ public UnmergedPathsException() {
public UnmergedPathsException(Throwable cause) {
super(JGitText.get().unmergedPaths, cause);
}
/**
* @param message
* @param cause
* @since 4.1
*/
public UnmergedPathsException(String message, Throwable cause) {
super(message, cause);
}
}

View File

@ -51,4 +51,25 @@
*/
public class DiffInterruptedException extends RuntimeException {
private static final long serialVersionUID = 1L;
/**
* @param message
* @param cause
* @since 4.1
*/
public DiffInterruptedException(String message, Throwable cause) {
super(message, cause);
}
/**
* @param message
* @since 4.1
*/
public DiffInterruptedException(String message) {
super(message);
}
public DiffInterruptedException() {
super();
}
}

View File

@ -56,6 +56,20 @@ public class LockFailedException extends IOException {
private File file;
/**
* @param file
* file that could not be locked
* @param message
* exception message
* @param cause
* cause, for later retrieval by {@link Throwable#getCause()}
* @since 4.1
*/
public LockFailedException(File file, String message, Throwable cause) {
super(message, cause);
this.file = file;
}
/**
* Construct a CannotLockException for the given file and message
*

View File

@ -55,6 +55,23 @@
public class ServiceNotAuthorizedException extends Exception {
private static final long serialVersionUID = 1L;
/**
* @param message
* @param cause
* @since 4.1
*/
public ServiceNotAuthorizedException(String message, Throwable cause) {
super(message, cause);
}
/**
* @param message
* @since 4.1
*/
public ServiceNotAuthorizedException(String message) {
super(message);
}
public ServiceNotAuthorizedException() {
super(JGitText.get().unauthorized);
}

View File

@ -49,6 +49,23 @@
public class ServiceNotEnabledException extends Exception {
private static final long serialVersionUID = 1L;
/**
* @param message
* @param cause
* @since 4.1
*/
public ServiceNotEnabledException(String message, Throwable cause) {
super(message, cause);
}
/**
* @param message
* @since 4.1
*/
public ServiceNotEnabledException(String message) {
super(message);
}
/** Indicates the request service is not available. */
public ServiceNotEnabledException() {
super(JGitText.get().serviceNotEnabledNoName);