What classes should I get my own DataAccessLayerException and DuplicateEntryException from?

I want to add the DataAccessLayerException and DuplicateEntryException classes. But I doubt very much from which classes should I get? For example, a DataAccessLayerException (to be used as a wrapper for exceptions thrown from the data access layer) can be obtained from an exception or a DbException. But I'm afraid that DbException should be the base class only for provider exceptions like OracleException or SqliteException etc. I dont know. And DuplicateEntryException (yes, I hate that this exception is not implemented by db providers, so I will create it myself) can be obtained from Exception or DbException or even from DataAccessLayerException.

What do you think? Also, please give reasons why you think so.

Please experienced developers / architects.

Thanks in advance.

+3
source share
2 answers

, Exception. , , DbException, , . , , , . , , . DbException, DbException , .

, DbException. , , DbExceptions, , -. , , . , .

P.S. , /, .

+1

, , System.Exception , . , "Foo", "FooException".

, , , , :

  • - , , , . - .
  • , , Exception DbException.
  • , - (, -/ node, ). , , , .

(, Foo.Core , Foo.Data , Foo.Services - Foo.UI ), , FooException. FooDataException, , DAL (, DuplicateEntryException), . FooServiceException FooUIException .

. , .

: ApplicationException, !

+1

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


All Articles