<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Design Exception Class in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/design-exception-class/m-p/12342397#M1992219</link>
    <description>&lt;P&gt;  &lt;SPAN class="mention-scrubbed"&gt;sandra.rossi&lt;/SPAN&gt; Thank you for your answer&lt;/P&gt;</description>
    <pubDate>Thu, 04 Feb 2021 20:03:20 GMT</pubDate>
    <dc:creator>hagit</dc:creator>
    <dc:date>2021-02-04T20:03:20Z</dc:date>
    <item>
      <title>Design Exception Class</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/design-exception-class/m-p/12342389#M1992211</link>
      <description>&lt;P&gt;Hello experts,&lt;/P&gt;
  &lt;P&gt;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. &lt;/P&gt;
  &lt;P&gt;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.&lt;/P&gt;
  &lt;P&gt;(See &lt;A href="https://answers.sap.com/questions/13235520/exception-class-with-more-than-one-exception.html"&gt;https://answers.sap.com/questions/13235520/exception-class-with-more-than-one-exception.html&lt;/A&gt;)&lt;/P&gt;
  &lt;P&gt;My question is – What is the right design? &lt;/P&gt;
  &lt;P&gt;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?&lt;/P&gt;
  &lt;P&gt;Thanks in advance&lt;/P&gt;
  &lt;P&gt;Hagit&lt;/P&gt;</description>
      <pubDate>Thu, 04 Feb 2021 14:35:27 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/design-exception-class/m-p/12342389#M1992211</guid>
      <dc:creator>hagit</dc:creator>
      <dc:date>2021-02-04T14:35:27Z</dc:date>
    </item>
    <item>
      <title>Re: Design Exception Class</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/design-exception-class/m-p/12342390#M1992212</link>
      <description>&lt;P&gt;The logic should be to have one exception by class or better by Interface (even if the exception is used by the class) &lt;/P&gt;&lt;P&gt;I try at least to have one exception class by logical set (a set for me is a Package and contains one or several class based on the same subject)&lt;/P&gt;&lt;P&gt;here the CleanCode &lt;/P&gt;&lt;P&gt;&lt;A href="https://github.com/SAP/styleguides/blob/master/clean-abap/CleanABAP.md#exceptions" target="test_blank"&gt;https://github.com/SAP/styleguides/blob/master/clean-abap/CleanABAP.md#exceptions&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 04 Feb 2021 14:55:45 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/design-exception-class/m-p/12342390#M1992212</guid>
      <dc:creator>FredericGirod</dc:creator>
      <dc:date>2021-02-04T14:55:45Z</dc:date>
    </item>
    <item>
      <title>Re: Design Exception Class</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/design-exception-class/m-p/12342391#M1992213</link>
      <description>&lt;P&gt;It depends. If all exceptions are handled the same way by the using program(s) and only the text varies, then it's useless creating many exception classes for nothing. Moreover, defining abstract text IDs may also not be needed if your using program(s) have the same behavior for all texts. Remember that an exception class works the same way as any other class, the only special thing is that it must inherit from CX_[STATIC|DYNAMIC|NO]_CHECK. e.g. you could implement your unique exception class such as you invoke it this way, with a dynamic text (implement the constructor accordingly + redefine GET_TEXT and GET_LONGTEXT):&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;RAISE EXCEPTION NEW zcx_xxx( text = 'my text'(001) ).&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 04 Feb 2021 15:00:52 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/design-exception-class/m-p/12342391#M1992213</guid>
      <dc:creator>Sandra_Rossi</dc:creator>
      <dc:date>2021-02-04T15:00:52Z</dc:date>
    </item>
    <item>
      <title>Re: Design Exception Class</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/design-exception-class/m-p/12342392#M1992214</link>
      <description>&lt;P&gt;  &lt;SPAN class="mention-scrubbed"&gt;frdric.girod&lt;/SPAN&gt;  Do you say that it is better to have many exception classes , which are united
in packages?&lt;/P&gt;</description>
      <pubDate>Thu, 04 Feb 2021 15:25:04 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/design-exception-class/m-p/12342392#M1992214</guid>
      <dc:creator>hagit</dc:creator>
      <dc:date>2021-02-04T15:25:04Z</dc:date>
    </item>
    <item>
      <title>Re: Design Exception Class</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/design-exception-class/m-p/12342393#M1992215</link>
      <description>&lt;P&gt;  &lt;SPAN class="mention-scrubbed"&gt;sandra.rossi&lt;/SPAN&gt;  Just to be sure that I understood you- The preferred way is to define
one exception class with dynamic text. Is it right?&lt;/P&gt;</description>
      <pubDate>Thu, 04 Feb 2021 17:13:10 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/design-exception-class/m-p/12342393#M1992215</guid>
      <dc:creator>hagit</dc:creator>
      <dc:date>2021-02-04T17:13:10Z</dc:date>
    </item>
    <item>
      <title>Re: Design Exception Class</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/design-exception-class/m-p/12342394#M1992216</link>
      <description>&lt;P&gt;It depends, as I explained.&lt;/P&gt;</description>
      <pubDate>Thu, 04 Feb 2021 17:25:52 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/design-exception-class/m-p/12342394#M1992216</guid>
      <dc:creator>Sandra_Rossi</dc:creator>
      <dc:date>2021-02-04T17:25:52Z</dc:date>
    </item>
    <item>
      <title>Re: Design Exception Class</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/design-exception-class/m-p/12342395#M1992217</link>
      <description>&lt;P&gt;If all exceptions are handled the same way by the using program(s) and only the text varies it is better to &lt;STRONG&gt;define one exception class&lt;/STRONG&gt; with dynamic text. Is it right?&lt;/P&gt;</description>
      <pubDate>Thu, 04 Feb 2021 17:34:31 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/design-exception-class/m-p/12342395#M1992217</guid>
      <dc:creator>hagit</dc:creator>
      <dc:date>2021-02-04T17:34:31Z</dc:date>
    </item>
    <item>
      <title>Re: Design Exception Class</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/design-exception-class/m-p/12342396#M1992218</link>
      <description>&lt;P&gt;Yes (it's how I do in those cases, I like KISS and YAGNI principles)&lt;/P&gt;&lt;P&gt;But probably people will have other opinions.&lt;/P&gt;</description>
      <pubDate>Thu, 04 Feb 2021 18:05:18 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/design-exception-class/m-p/12342396#M1992218</guid>
      <dc:creator>Sandra_Rossi</dc:creator>
      <dc:date>2021-02-04T18:05:18Z</dc:date>
    </item>
    <item>
      <title>Re: Design Exception Class</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/design-exception-class/m-p/12342397#M1992219</link>
      <description>&lt;P&gt;  &lt;SPAN class="mention-scrubbed"&gt;sandra.rossi&lt;/SPAN&gt; Thank you for your answer&lt;/P&gt;</description>
      <pubDate>Thu, 04 Feb 2021 20:03:20 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/design-exception-class/m-p/12342397#M1992219</guid>
      <dc:creator>hagit</dc:creator>
      <dc:date>2021-02-04T20:03:20Z</dc:date>
    </item>
    <item>
      <title>Re: Design Exception Class</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/design-exception-class/m-p/12342398#M1992220</link>
      <description>&lt;P&gt;  &lt;SPAN class="mention-scrubbed"&gt;sandra.rossi&lt;/SPAN&gt; When a program catches
an exception, it displays a message and exit. Could you please give an example
for a case that the calling program handle the exception in another way?&lt;/P&gt;</description>
      <pubDate>Thu, 04 Feb 2021 20:58:27 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/design-exception-class/m-p/12342398#M1992220</guid>
      <dc:creator>hagit</dc:creator>
      <dc:date>2021-02-04T20:58:27Z</dc:date>
    </item>
    <item>
      <title>Re: Design Exception Class</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/design-exception-class/m-p/12342399#M1992221</link>
      <description>&lt;P&gt;I understand the KISS principle, but I prefer the SOLID. And SOLID contains the No-dependency rules.&lt;/P&gt;&lt;P&gt;Sometimes CleanCode is not really the simple way &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;P&gt;(If you have few exception class, used in a lot of place, and someone would like to make a change ... the dependencies will be a nightmare.)&lt;/P&gt;</description>
      <pubDate>Fri, 05 Feb 2021 07:39:52 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/design-exception-class/m-p/12342399#M1992221</guid>
      <dc:creator>FredericGirod</dc:creator>
      <dc:date>2021-02-05T07:39:52Z</dc:date>
    </item>
    <item>
      <title>Re: Design Exception Class</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/design-exception-class/m-p/12342400#M1992222</link>
      <description>&lt;P&gt; &lt;SPAN class="mention-scrubbed"&gt;sandra.rossi&lt;/SPAN&gt; Suggestion to convert this to an answer. &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 05 Feb 2021 20:12:28 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/design-exception-class/m-p/12342400#M1992222</guid>
      <dc:creator>Jelena_Perfiljeva</dc:creator>
      <dc:date>2021-02-05T20:12:28Z</dc:date>
    </item>
    <item>
      <title>Re: Design Exception Class</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/design-exception-class/m-p/12342401#M1992223</link>
      <description>&lt;P&gt;Example where the calling program handle exceptions in different ways:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;  TRY.&lt;BR /&gt;      create_something( ).&lt;BR /&gt;    CATCH zcx_already_exists.&lt;BR /&gt;      log_warning( ).&lt;BR /&gt;    CATCH cx_root.
      log_critical_error( ).
  ENDTRY.&lt;BR /&gt;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 06 Feb 2021 08:58:56 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/design-exception-class/m-p/12342401#M1992223</guid>
      <dc:creator>Sandra_Rossi</dc:creator>
      <dc:date>2021-02-06T08:58:56Z</dc:date>
    </item>
    <item>
      <title>Re: Design Exception Class</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/design-exception-class/m-p/12342402#M1992224</link>
      <description>&lt;P&gt;Please try the below one.&lt;/P&gt;&lt;P&gt;Data : oref_root TYPE REF TO cx_root,  "Object for Global Exception Class&lt;/P&gt;&lt;P&gt;          lv_error_message TYPE char150.  "Variable to capture Error Message&lt;/P&gt;&lt;P&gt;TRY.&lt;/P&gt;&lt;P&gt;        " &amp;lt;CODE_TO BE_EXECTUTED&amp;gt;&lt;/P&gt;&lt;P&gt;   CATCH cx_root INTO oref_root.&lt;/P&gt;&lt;P&gt;         lv_error_message = oref_root-&amp;gt;get_text( ).   "Capture Exception Message&lt;/P&gt;&lt;P&gt;ENDTRY.&lt;/P&gt;&lt;P&gt;Hope this will fulfill your requirement. Let know if this helped you.&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Ranjith M R.&lt;/P&gt;</description>
      <pubDate>Sat, 06 Feb 2021 09:55:13 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/design-exception-class/m-p/12342402#M1992224</guid>
      <dc:creator>ranjith9596</dc:creator>
      <dc:date>2021-02-06T09:55:13Z</dc:date>
    </item>
    <item>
      <title>Re: Design Exception Class</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/design-exception-class/m-p/12342403#M1992225</link>
      <description>&lt;P&gt;  &lt;SPAN class="mention-scrubbed"&gt;ranjith9596&lt;/SPAN&gt; Thank you for your answer. You show how to catch an exception and display
its text.&lt;/P&gt;&lt;P&gt;My first question is: In the entire
system, for exceptions which, are handled the same way by the calling
programs, should I create only one exception class with many text ids, or
is it better to create several exception classes? If it is better to create
several exception classes, what is the preferred division of exception classes?&lt;/P&gt;&lt;P&gt;The second question is: When an exception is caught, usually the calling
program display a message and exit. Could you please give an example for a
different response to an exception?&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;Hagit&lt;/P&gt;</description>
      <pubDate>Sun, 07 Feb 2021 07:03:31 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/design-exception-class/m-p/12342403#M1992225</guid>
      <dc:creator>hagit</dc:creator>
      <dc:date>2021-02-07T07:03:31Z</dc:date>
    </item>
    <item>
      <title>Re: Design Exception Class</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/design-exception-class/m-p/12342404#M1992226</link>
      <description>&lt;P&gt;  &lt;SPAN class="mention-scrubbed"&gt;sandra.rossi&lt;/SPAN&gt; , Thanks for your anaswer.&lt;/P&gt;&lt;P&gt;Do you create an exception for warning? I thought that an exception is
for blocking.&lt;/P&gt;</description>
      <pubDate>Sun, 07 Feb 2021 07:52:56 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/design-exception-class/m-p/12342404#M1992226</guid>
      <dc:creator>hagit</dc:creator>
      <dc:date>2021-02-07T07:52:56Z</dc:date>
    </item>
    <item>
      <title>Re: Design Exception Class</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/design-exception-class/m-p/12342405#M1992227</link>
      <description>&lt;P&gt;No, an exception is for an exception, like attempting to create something that already exists. A warning must not be an exception.&lt;/P&gt;&lt;P&gt;log_warning is just a method to log the exception like a warning. But it was not my intention to discuss what is executed inside the catch, my intention was to show how two exceptions can be handled differently, which was your question (should I create only one exception class or several exception classes).&lt;/P&gt;&lt;P&gt;You have difficulties to understand that there can't be one answer to "should I create one or several exception classes". It's like the question "what is the best programming language": it depends.&lt;/P&gt;&lt;P&gt;So, let me repeat, differently. If you just need one exception handling like this:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;TRY.
    do_something( ).
  CATCH zcx_any_error INTO DATA(the_error).
    WRITE / the_error-&amp;gt;get_text( ).
ENDTRY.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;then, I repeat: "you could implement your unique exception class such as you invoke it this way, with a dynamic text (implement the constructor accordingly + redefine GET_TEXT and GET_LONGTEXT)":&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;RAISE EXCEPTION NEW zcx_any_error( text = 'my text'(001) ).&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 07 Feb 2021 08:31:39 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/design-exception-class/m-p/12342405#M1992227</guid>
      <dc:creator>Sandra_Rossi</dc:creator>
      <dc:date>2021-02-07T08:31:39Z</dc:date>
    </item>
  </channel>
</rss>

