Exceptions Flashcards

1
Q

What are throwing exceptions used for?

A

Allows for relevant information to be collected and returned as a bundle when something goes wrong (aids debugging)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Should we throw everything?

A

No. Anything can be thrown but not everything should be thrown.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Why should we throw the relevant derived std::exception.

A

So that users can program separate catch statements to handle each exception individually. Allows for further debugging.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What can put in the function declaration to indicate it does not throw an exception?

A

noexcept

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What could we do to customise our own exceptions?

A
  • Overriding the what() operation.
  • Writing own own functions to provide this information
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

How would we catch multiple different exceptions?

A

Using multiple catch blocks.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Why should we use exceptions with resource allocation?

A

To help clean up resources.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Why should we embrace the RAII? principle?

A

Allows us to write code that does automatic clean up with exceptions.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Why should we embrace abstractions?

A

Allows us to rely on the code to sort out memory management.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly