Default Constructor on exceptions not recognised
Issue #1328
resolved
When you have an exception:
public class MyException extends Exception {
public Integer statusCode {get; set;}
public String message {get; set;}
public MyException(Integer statusCode, String message){
this.statusCode = statusCode;
this.message = message;
}
}
you can call this exception with just:
throw new MyException('My Message');
However, in IC it’s saying this is invalid although this compiles and saves.
Comments (2)
-
repo owner -
repo owner - changed status to resolved
This is obviously quite old, but I'm unable to reproduce this behavior with the following:
public with sharing class Issue1328Exception extends Exception { private Integer statusCode { get; set; } private String message { get; set; } public Issue1328Exception(Integer statusCode, String message) { this.statusCode = statusCode; this.message = message; } public static void testIt() { throw new Issue1328Exception('My Message'); } }
If you still see this behavior, please reopen with any details on how you're reproducing it.
- Log in to comment
I could swear that I implemented some special handling for this given how Apex
Exception
constructors behave. I'll take a look...