Design: Custom Exception Usage



I have a design question that I would like to get some opinions on.

I have a class (ClassA) that uses a custom exception (ExceptionA). The
class and exception are defined together in one assembly.

I have ClassB that uses ClassA. If an ExceptionA is thrown from ClassA, the
users of ClassB may need to catch it.

I would prefer the users of ClassB to not need to reference ClassA for the
sole purpose of catching its exceptions. I was thinking of making a subclass
ExceptionB : ExceptionA (direct encapsulation) and catching and rethrowing.

I think this is too much effort. What are your thoughts on situations like
this?


Thanks
.



Relevant Pages

  • Re: Design: Custom Exception Usage
    ... ExceptionA is defined outside of ClassA but within the same ... My concern is that the user of ClassB must reference ... all ExceptionA exceptions in ClassB and rethrowing them as ExceptionB ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Design: Custom Exception Usage
    ... I have a class (ClassA) that uses a custom exception (ExceptionA). ... I have ClassB that uses ClassA. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Design: Custom Exception Usage
    ... I have a class (ClassA) that uses a custom exception (ExceptionA). ... I have ClassB that uses ClassA. ... ExceptionA and catching and rethrowing. ...
    (microsoft.public.dotnet.languages.csharp)

Loading