styleguides icon indicating copy to clipboard operation
styleguides copied to clipboard

Mention "Exception chaining" in "Wrapping foreign exceptions" chapter

Open nununo opened this issue 2 years ago • 3 comments

In the chapter about wrapping foreign exceptions I think it would be worth mentioning that what is being proposed is called exception chaining.

My suggestion is to change this sentence:

Make yourself independent from the foreign code by catching those exceptions and wrapping them in an exception type of your own.

Into this:

Make yourself independent from the foreign code by using exception chaining: catch those exceptions and wrap them in an exception type of your own.

If approved I can make a PR.

nununo avatar Aug 24 '21 11:08 nununo

TBH, I've never heard the term "Exception Chaining" being used in an ABAP context. "Wrapping" not he other hand is something we rely on heavily in the ABAP world and therefore this is IMHO more easily understood. Chaining is a special feature of ABAP and has a different meaning from most other languages. Some may think exception chaining means CATCH: zcx_foo, lcx_bar, lcx_moo. (definitely not a recommended construct!). So on balance my opinion is to leave it as wrapping.

pokrakam avatar Aug 24 '21 14:08 pokrakam

I understand what you're saying. I would argue though that at least part of Clean ABAP's goals is to align ABAP with other languages, by leveraging all these widely-used cross-language best practices. In that sense, I don't see any harm in mentioning exception chaining, it being a well-known cross-language concept, with its own Wikipedia page.

Btw, my suggestion was to mention exception chaining without removing wrapping which I agree is the most important concept here.

It is definitely a minor detail, though, and nothing I'd fight for :-) so, if you think it will confuse rather than clarify, please feel free to close it if you don't find it worth pursuing.

Thanks!

nununo avatar Aug 24 '21 14:08 nununo

It's not for me to close, others may have different opinions so lets see 🙂 It may be worth adding a side note such as also known as exception chaining in other languages.

FWIW, the Clean Code book uses the terms translating and wrapping exceptions.

pokrakam avatar Aug 24 '21 15:08 pokrakam