Skip to Content
0
Feb 04, 2021 at 02:35 PM

Design Exception Class

121 Views

Hello experts,

When an exception is caught, I need to display a message and exit the program. Every case has its own message. The exception is raised by methods, therefor I use an exception class.

I understand that I can create one exception class with many Text Ids. Different methods will raise the exception class with a different Text Id. In that way it is possible to create only one exception class in the entire system.

(See https://answers.sap.com/questions/13235520/exception-class-with-more-than-one-exception.html)

My question is – What is the right design?

Is it recommended to create only one exception class in the entire system or is it better to create several exception classes? Maybe an exception class for each message class? Or a different division of exception classes?

Thanks in advance

Hagit