function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
asadimasadim 

Custom Exception message

Hi,

 

I have a custom exception class like so:

 

 

global class MyException extends Exception {
    
    global Boolean isCritical { get; private set; }
    
    global MyException( String msg, Boolean isCritical)
    {
        this(msg);
        this.isCritical = isCritical;
    }
}

 

 

But when MyException is thrown and caught the message that I get says "script-throw exception" as opposed to the message that I had specified.

 

Any ideas on how to get the message out of the exception? Thanks.

Corey_BCorey_B

Old thread, but I showed up here looking for the same information.

 

Change 

this(msg);

 

to 

this.setMessage(msg);