← Back to Exceptions
Question 742
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= newline. The output ends with a newline — print one after the last line.
Hints4 available
Sign in to use hintsTopics:
Exceptions
1
Tab to indent (Esc then Tab to move on) · Ctrl+Enter to run · Shift+Alt+F to format · 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.