It really depends on the semantics of the functions in question. In general, if you are writing a library, your library should probably handle the exceptions that occur in the library (possibly recreating them as new exceptions for the library).
However, at the level of individual functions, the main thing you want to think about is what context / area in which you want to handle the exception - if there is a reasonable difference that you could make in exceptional cases inside an internal function, it would be useful to handle it inside an internal function; otherwise, it may make sense to handle it in an external function.
For a particular case of writing output, it is often useful to do this only at the highest level, and internal functions only ever (a) return values ββor (b) throw exceptions. This simplifies code verification because you donβt have to worry about testing a side effect.
source share