From 6a531d450a993e5fce9383670708ebc370208a76 Mon Sep 17 00:00:00 2001 From: Marko Luukkainen Date: Tue, 14 Sep 2021 14:48:37 +0300 Subject: [PATCH] Message of an Exception may be null. Changed messageOfException function to return empty String when message is null. Added possibleMessageOfException to return Maybe String gitlab #749 Change-Id: Ia67cbef6bbc67c7c0c6fc15a69bd11d46f76e431 --- bundles/org.simantics.scl.runtime/scl/Prelude.scl | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/bundles/org.simantics.scl.runtime/scl/Prelude.scl b/bundles/org.simantics.scl.runtime/scl/Prelude.scl index 86d13fb66..dc25349c8 100644 --- a/bundles/org.simantics.scl.runtime/scl/Prelude.scl +++ b/bundles/org.simantics.scl.runtime/scl/Prelude.scl @@ -2264,7 +2264,7 @@ importJava "java.lang.Throwable" where showThrowable :: Throwable -> String @private @JavaName getMessage - getMessageThrowable :: Throwable -> String + getMessageThrowable :: Throwable -> Maybe String @private @JavaName getCause getCauseThrowable :: Throwable -> Maybe Throwable @@ -2283,7 +2283,12 @@ class Throwable e where toThrowable :: e -> Throwable messageOfException :: Throwable e => e -> String -messageOfException = getMessageThrowable . toThrowable +messageOfException e = match getMessageThrowable $ toThrowable e with + Just m -> m + Nothing -> "" + +possibleMessageOfException :: Throwable e => e -> Maybe String +possibleMessageOfException e = getMessageThrowable $ toThrowable e causeOfException :: Throwable e => e -> Maybe Throwable causeOfException = getCauseThrowable . toThrowable -- 2.45.2