Skip to content

Commit

Permalink
This is an exceptional commit message
Browse files Browse the repository at this point in the history
  • Loading branch information
jodygarnett committed Mar 30, 2017
1 parent 9f935bc commit 69c1033
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 11 deletions.
Expand Up @@ -390,10 +390,7 @@ public static List<Resource> listRecursively(Resource dir) {
} }


/** /**
*
* File Extension based filtering * File Extension based filtering
*
*
*/ */
public static class ExtensionFilter implements Filter<Resource> { public static class ExtensionFilter implements Filter<Resource> {


Expand Down
@@ -1,15 +1,20 @@
package org.geoserver.rest; package org.geoserver.rest;


import org.springframework.http.HttpStatus;

/** /**
* Handling for 404 type exceptions * Explicit exception for {@link HttpStatus#NOT_FOUND} (404) exceptions.
*/ */
public class ResourceNotFoundException extends RuntimeException { public class ResourceNotFoundException extends RestException {

/** serialVersionUID */
private static final long serialVersionUID = 4656222203528783838L;


public ResourceNotFoundException() { public ResourceNotFoundException() {
super(); super("Not Found",HttpStatus.NOT_FOUND);
} }


public ResourceNotFoundException(String s) { public ResourceNotFoundException(String message) {
super(s); super(message, HttpStatus.NOT_FOUND);
} }
} }
31 changes: 28 additions & 3 deletions src/rest-ng/src/main/java/org/geoserver/rest/RestException.java
@@ -1,24 +1,49 @@
/* (c) 2017 - 2016 Open Source Geospatial Foundation - all rights reserved
* This code is licensed under the GPL 2.0 license, available at the root
* application directory.
*/
package org.geoserver.rest; package org.geoserver.rest;


import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;


/** /**
* General purpose rest exceptions * Rest Exception including {@link HttpStatus} code.
*/ */
public class RestException extends RuntimeException { public class RestException extends RuntimeException {
/** serialVersionUID */
private static final long serialVersionUID = 5762645820684796082L;

private final HttpStatus status; private final HttpStatus status;


public RestException(String message, HttpStatus status) { public RestException(String message, HttpStatus status) {
super(message); super(message);
this.status = status; this.status = status;
} }


public RestException(String s, HttpStatus status, Throwable t) { public RestException(String message, HttpStatus status, Throwable t) {
super(s, t); super(message, t);
this.status = status; this.status = status;
} }


public HttpStatus getStatus() { public HttpStatus getStatus() {
return status; return status;
} }

@Override
public String toString() {
StringBuilder builder = new StringBuilder();
builder.append(getClass().getName());
if( status != null ){
builder.append(" ");
builder.append(status.value());
builder.append(" ");
builder.append(status.name());
}
String message = getLocalizedMessage();
if( message != null ){
builder.append(": ");
builder.append( message );
}
return builder.toString();
}
} }

0 comments on commit 69c1033

Please sign in to comment.