Why do I want to replace the exception?

I am using Enterprise Library 5.0, a tool for managing cross-cutting issues such as logging.

One of the options that the tool gives me is to โ€œreplaceโ€ the exception. In some cases, I see the purpose of the wrapping, but why should I even want to completely replace the exception?

thanks

+4
source share
4 answers

What if the original exception contains confidential, proprietary data or similar data, and you just wanted to replace it with a wholesale one? This may be one case when the packaging is not suitable, because what you want to do is to separate the sensitive parts, but keep the basic set of technical information. I had similar problems in the past with financial applications in which, for example, you do not want to send complete logs to the system to the supplier. In this case, there have been several attempts to explicitly separate the sensitive and insensitive error handling to various traps.

+4
source

There are many reasons to replace a mistake, and, like other answers, security is one of them, but not the only one. Sometimes you can simply improve your API so that the different levels of your application respond to things that make sense. For example, I would not expect the desktop application user interface to catch an SQL exception by parsing this exception, and then inform the user that a duplicate key was found in the database. Instead, you may have a custom exception called a DuplicateRecordException that is thrown from the data access layer. This exception may include the original exception as an InnerException, but now you have an exception that leaves the DAL, which makes sense in terms of the user interface level.

+2
source

I do not know if this is applicable, but WCF also has such a function. Transferring all error information along a partition boundary is sometimes a security risk.

+1
source

I assume you are talking about an exception handling block? For some time I studied it, trying to find meaning. Admittedly, I still do not understand, but this is a professional responsibility. As far as I can tell, this gives IT professionals some control over how exceptions are reported and handled.

What is relevant in an enterprise, where the gap between departments between people who create exceptions (software developers) and people who deal with them (IT staff and users) can be difficult to bridge. Failing a code with an impenetrable exception message is too common, so fixing them with a lot of intermediate control levels between them can be quite complicated and time consuming. In this case, a script that can improve diagnostics and help the user avoid making the same mistake, instead of killing the corporate dragon, makes a lot of sense.

+1
source

Source: https://habr.com/ru/post/1333510/


All Articles