Add verigraph code base
[parser.git] / verigraph / src / main / java / it / polito / escape / verify / exception / InternalServerErrorExceptionMapper.java
1 /*******************************************************************************
2  * Copyright (c) 2017 Politecnico di Torino and others.
3  *
4  * All rights reserved. This program and the accompanying materials
5  * are made available under the terms of the Apache License, Version 2.0
6  * which accompanies this distribution, and is available at
7  * http://www.apache.org/licenses/LICENSE-2.0
8  *******************************************************************************/
9
10 package it.polito.escape.verify.exception;
11
12 import javax.ws.rs.core.Response;
13 import javax.ws.rs.core.Response.Status;
14 import javax.ws.rs.ext.ExceptionMapper;
15 import javax.ws.rs.ext.Provider;
16
17 import it.polito.escape.verify.model.ErrorMessage;
18
19 @Provider
20 public class InternalServerErrorExceptionMapper implements ExceptionMapper<InternalServerErrorException> {
21
22         @Override
23         public Response toResponse(InternalServerErrorException exception) {
24                 ErrorMessage errorMessage = new ErrorMessage(   exception.getMessage(),
25                                                                                                                 500,
26                                                                                                                 "http://localhost:8080/verify/api-docs/");
27                 return Response.status(Status.INTERNAL_SERVER_ERROR).entity(errorMessage).build();
28         }
29
30 }