Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the use of adding an exception to a method of a global class?

Tags:

exception

abap

So, I added this image, hoping it would help : Method exception

My question is: What is the point of doing this? I have created my global exception class(with my own messages), I have raised it in a method of a global class and I have also caught this exception - and I have done all these without giving that particular method the exception, so does it help in any way to give a method exceptions?

Short update, this is my method code: Method code

A coworker told me to give the method an exception parameter instead of writing the code from picture 2. If I do so, I don't see any changes and this is why I do not see the point of doing what is in the first picture.

like image 811
Ovidiu Pocnet Avatar asked Nov 30 '25 06:11

Ovidiu Pocnet


1 Answers

This is a very good question. Because of the overhead, such exceptions create either by creating them, adding them, linking them to a message-class and throwing/catching them, it really, also for me, seems sometimes a kind of "shooting rockets at birds". Most things can really be caught by catching CX_ROOT. Nevertheless there are really cases, where it is important to distinguish between exceptions, and therefore it is a nice-oop-standard to create some own, If:

  • the exception's class type/meaning cannot be covered by the abap-standard exceptions
  • the exception class should be linked against own message-class-messages
  • the exception class should provide special features like "resumable".

In the end this question is some kind of "best practice/best usecase" question and I also would be glad to see some other answers, which can pinpoint to other points of view about this topic.

like image 163
icbytes Avatar answered Dec 04 '25 04:12

icbytes



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!