From e971a68d6e9ed19686706cf3b26a753f2b6e848a Mon Sep 17 00:00:00 2001 From: Felix Sidokhine <felix.sidokhine@savoirfairelinux.com> Date: Thu, 18 Jun 2020 15:07:14 +0300 Subject: [PATCH] fixed bad gitignore Change-Id: Id56a6d0b26e9224cd7449765bb818e96e3abdea5 --- .gitignore | 2 +- .../tomcat/TomcatCustomErrorHandler.java | 40 +++++++++++++++++++ 2 files changed, 41 insertions(+), 1 deletion(-) create mode 100644 jams-common/src/main/java/net/jami/jams/common/serialization/tomcat/TomcatCustomErrorHandler.java diff --git a/.gitignore b/.gitignore index b3d6a614..4288729a 100644 --- a/.gitignore +++ b/.gitignore @@ -89,5 +89,5 @@ fabric.properties log/ target/ testdb/ -tomcat*/ +tomcat.*/ /jams \ No newline at end of file diff --git a/jams-common/src/main/java/net/jami/jams/common/serialization/tomcat/TomcatCustomErrorHandler.java b/jams-common/src/main/java/net/jami/jams/common/serialization/tomcat/TomcatCustomErrorHandler.java new file mode 100644 index 00000000..2defb5b0 --- /dev/null +++ b/jams-common/src/main/java/net/jami/jams/common/serialization/tomcat/TomcatCustomErrorHandler.java @@ -0,0 +1,40 @@ +/* +* Copyright (C) 2020 by Savoir-faire Linux +* Authors: William Enright <william.enright@savoirfairelinux.com> +* Ndeye Anna Ndiaye <anna.ndiaye@savoirfairelinux.com> +* Johnny Flores <johnny.flores@savoirfairelinux.com> +* Mohammed Raza <mohammed.raza@savoirfairelinux.com> +* Felix Sidokhine <felix.sidokhine@savoirfairelinux.com> +* +* +* 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 3 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 <https://www.gnu.org/licenses/>. +*/ +package net.jami.jams.common.serialization.tomcat; + +import jakarta.servlet.http.HttpServletResponse; +import lombok.extern.slf4j.Slf4j; + +@Slf4j +public class TomcatCustomErrorHandler { + + public static void sendCustomError(HttpServletResponse resp,int errorCode, String text){ + try { + resp.setStatus(errorCode); + resp.getOutputStream().write(("{\"error\":\"" + text + "\"}").getBytes()); + } + catch (Exception e){ + log.error("Could not generate an error!"); + } + } +} -- GitLab