diff options
| author | Tim <timothyasir@gluster.com> | 2011-07-11 14:39:13 +0530 |
|---|---|---|
| committer | Tim <timothyasir@gluster.com> | 2011-07-11 14:39:13 +0530 |
| commit | 3e10145c363971d75181348886672fffa62ef3c9 (patch) | |
| tree | 337a19be25611a0af48d7b65db95fef41541f6b7 /src/com.gluster.storage.management.server | |
| parent | 6be4e159af3a14a80250626ac405076e458b921f (diff) | |
| parent | efe32527e41e28b30b0393f9963daad608ec5c2c (diff) | |
Merge remote branch 'upstream/master'
Diffstat (limited to 'src/com.gluster.storage.management.server')
| -rw-r--r-- | src/com.gluster.storage.management.server/src/com/gluster/storage/management/server/resources/v1_0/GlusterExceptionMapper.java | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/src/com.gluster.storage.management.server/src/com/gluster/storage/management/server/resources/v1_0/GlusterExceptionMapper.java b/src/com.gluster.storage.management.server/src/com/gluster/storage/management/server/resources/v1_0/GlusterExceptionMapper.java new file mode 100644 index 00000000..99089eb7 --- /dev/null +++ b/src/com.gluster.storage.management.server/src/com/gluster/storage/management/server/resources/v1_0/GlusterExceptionMapper.java @@ -0,0 +1,39 @@ +/******************************************************************************* + * Copyright (c) 2011 Gluster, Inc. <http://www.gluster.com> + * This file is part of Gluster Management Console. + * + * Gluster Management Console is free software; you can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Gluster Management Console is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License + * for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see + * <http://www.gnu.org/licenses/>. + *******************************************************************************/ +package com.gluster.storage.management.server.resources.v1_0; + +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; +import javax.ws.rs.ext.ExceptionMapper; +import javax.ws.rs.ext.Provider; + +import com.gluster.storage.management.core.exceptions.GlusterRuntimeException; + +@Provider +public class GlusterExceptionMapper implements ExceptionMapper<GlusterRuntimeException> { + + /* (non-Javadoc) + * @see javax.ws.rs.ext.ExceptionMapper#toResponse(java.lang.Throwable) + */ + @Override + public Response toResponse(GlusterRuntimeException exception) { + return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(exception.getMessage()) + .type(MediaType.TEXT_PLAIN).build(); + } +} |
