I was wondering if there is a right place to handle exceptions. Should I handle it inside my method or should I handle it at the method call? Or does it matter at all?
I'm sorry, but I couldn't find anything about this (googling "exception handling scope" didn't returned what I was looking for).
Example:
// this way...
void readFile(string file)
{
try
{
/* do my stuff */
}
catch(Exception exception)
{
/* handle exception */
}
}
int main()
{
readFile(file);
}
// or this way?
void readFile(string file)
{
/* do my stuff */
}
int main()
{
try
{
readFile(file);
}
catch(Exception exception)
{
/* handle exception */
}
}
Thanks in advance.