From: Marko Luukkainen Date: Tue, 14 Sep 2021 11:48:37 +0000 (+0300) Subject: Message of an Exception may be null. X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=commitdiff_plain;h=6a531d450a993e5fce9383670708ebc370208a76;p=simantics%2Fplatform.git 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 --- 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