โ Back to Exceptions
Question 652
Exception Filter With when
Exception Filter With when
Read an integer status code. If it is>= 400,throw new Exception(code.ToString()); otherwise printSuccess. Use an exception filter:catch (Exception ex) when (ex.Message == "404")printsNot Found, and a secondcatch (Exception)printsOther error. Use top-level statements. Input200prints: Success Input404prints: Not Found Input500prints: Other error
Expected Output:
Success
Topics:
Exceptions
Code Editor
1
Tab to indent ยท Ctrl+Enter to run ยท Ctrl+Space to expand shortcuts (cw, cr, fori)
Your Output
Run your code to see the output here...
Test Cases
Run your code to see test case results.