From ed7863329118a7cd1c91c8017c08b8360d5c0f14 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20Garcia=20Nu=C3=B1ez?= Date: Fri, 20 Dec 2019 17:57:56 +0100 Subject: [PATCH] =?UTF-8?q?Nuevo=20m=C3=A9todo=20para=20obtener=20la=20cau?= =?UTF-8?q?sa=20raiz=20de=20una=20excepci=C3=B3n.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 1.sources/MyHealth/src/common/Utils.java | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/1.sources/MyHealth/src/common/Utils.java b/1.sources/MyHealth/src/common/Utils.java index 0926f7e..278b248 100644 --- a/1.sources/MyHealth/src/common/Utils.java +++ b/1.sources/MyHealth/src/common/Utils.java @@ -1,6 +1,7 @@ package common; import java.text.Normalizer; +import java.util.Objects; /** * @@ -11,9 +12,18 @@ public class Utils { public static String stripAccents(String input) { return input == null ? null : Normalizer.normalize(input, Normalizer.Form.NFD).replaceAll("\\p{InCombiningDiacriticalMarks}+", ""); } - + public static String normalizeTerm(String input) { - //return stripAccents(input).toLowerCase(); + // return stripAccents(input).toLowerCase(); return input.toLowerCase(); } + + public static Throwable getExceptionRootCause(Throwable throwable) { + Objects.requireNonNull(throwable); + Throwable rootCause = throwable; + while (rootCause.getCause() != null && rootCause.getCause() != rootCause) { + rootCause = rootCause.getCause(); + } + return rootCause; + } }