Here's an example:
public class Teste
{
public static void main(String[] args)
{
func1();
}
public static void func1()
{
try
{
func2();
}
catch (Exception e)
{
System.err.println("Error 1\n");
}
}
public static void func2()
{
try
{
int x = 1 / 0;
}
catch (Exception e)
{
System.err.println("Error 2\n");
}
}
}
Output:
Error 2
Is it possible to cause that as soon as the error occurs in func2
it printe Error 2
and trigger that error to func1
printing Error 1
as in the output example below?
Error 2
Error 1