나는 C#을 사용 중이고 try/catch
에서 예외를 다시 발생시키고 나중에 catch
문을 다시 호출 할 수 있는지 궁금해하셨습니까?예외 재발행 및 다시 잡기
try {
// 1. Try some operation
//Failed operations
// 2. Throw an exception
throw new IOException("I tried my best");
} catch(IOException) {
// 3. Try some specific recovery operation
//Failed operations
//4. Rethrow and try again
throw;
}
... Some more specific exception handlers
} catch(Exception) {
// 5. Re-caught here as a last-ditch effort, generic recovery operation
//Process here
} finally {
//...
}
try/catch 블록을 중첩 할 수 있습니다. – NicoD
답변 : 예! 하지만 다른 범위에서만 :) –
같은 try-catch는 아니지만 상위 레벨 –