Java tutorial
/* * Copyright (c) 2016 Platypus Knowledge Base developers. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 2 of the License, or * (at your option) any later version. * * This program 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ package us.askplatyp.kb.lucene.model; import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.util.Map; import java.util.TreeMap; /** * @author Thomas Pellissier Tanon */ @JsonSerialize(as = ApiError.class) public class ApiException extends Exception implements ApiError { private static Map<String, Object> CONTEXT = new TreeMap<>(); static { CONTEXT.put("@vocab", "http://schema.org/"); } private int httpStatus = 500; public ApiException(Throwable cause) { super(cause); } public ApiException(String message) { super(message); } public ApiException(String message, int httpStatus) { super(message); this.httpStatus = httpStatus; } public ApiException(String message, Throwable cause) { super(message, cause); } public ApiException(String message, Throwable cause, int httpStatus) { super(message, cause); this.httpStatus = httpStatus; } public Map<String, Object> getContext() { return CONTEXT; } public String getType() { return "Error"; } public int getStatus() { return httpStatus; } }