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
mikeafter6mikeafter6 

Trying to create Exception Inheritance Tree; non-virtual and non-abstract type cannot be extended

I get the following error when trying to create a hierarchy of exception classes.

 

Save error: NoPersonLinkException: Non-virtual and non-abstract type cannot be extended: InvalidUserUserException
 

Samples in docs don't use virtual or abstract keywords when extending exception classes.  

Please advise on syntax.

 

//FIRST CLASS:
public class InvalidUserException extends Exception{}

//SECOND CLASS:
public class NoPersonLinkException extends InvalidUserException{}

 

 

 

 

AlsoDougAlsoDoug

With Apex you can only extend an abstract class (or from what I have seen).

 

Since you are trying to extend the first class with the second class, you would need to have your first class created as abstract.

 

Doug

PetteroePetteroe

Does that mean that there is no way to reuse Accounts for our special case of Merchant? I would like to keep the built-in behaviour for Accounts with our Merchant object type without having to clutter the Accounts with unnecessary fields.

 

Morten