blob: 1d9c38397673f97db47f0e72bb9718acfdb84ca2 [file] [log] [blame]
/********************************************************************************
* Copyright (c) 2015-2018 Contributors to the Eclipse Foundation
*
* See the NOTICE file(s) distributed with this work for additional
* information regarding copyright ownership.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0.
*
* SPDX-License-Identifier: EPL-2.0
*
********************************************************************************/
package org.eclipse.mdm.businessobjects.service;
import org.eclipse.mdm.businessobjects.utils.ServiceUtils;
import javax.ws.rs.core.Response;
import javax.ws.rs.ext.ExceptionMapper;
import javax.ws.rs.ext.Provider;
/**
* {@link ExceptionMapper} implementation handling exceptions in a generic way
* As most of backend related exceptions are handled within the
* {@link io.vavr.control.Try}s this handler is the last fallback to provide
* some prepared response in an error case
*
* @author Alexander Nehmer, science + computing ag Tuebingen, ATOS SE)
*
*/
@Provider
public class GenericExceptionMapper implements ExceptionMapper<Throwable> {
@Override
public Response toResponse(Throwable t) {
return ServiceUtils.handleGenericExceptions(t);
}
}