A
A
Alex Serov2015-04-25 20:05:24
OOP
Alex Serov, 2015-04-25 20:05:24

What is the best way to write your own exception class for your library?

Interests from what that it is necessary to inherit.
For example, there is a string class.
We will throw an exception when we try to access a non-existent character of a string.
If we make our own exception class, then do we need to inherit the ExceptionOutOfRange class multiple from std::out_of_range and our own Exception?
Is it worth making such a class at all, and not throwing std::out_of_range?
And similar questions.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
O
OnYourLips, 2015-04-25
@gibsonman01

You need your own class, inherited from the standard one.
Causes?
Because when processing, sometimes different actions are needed: for errors in a specific library and for a general error.
You need several classes for different occasions.
Causes?
Library users will want to handle different errors differently.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question