← Back to Exceptions
Question 774
Filter With a when Clause
Filter With a when Clause
Read an integercode, thenthrow new InvalidOperationException(code.ToString()). Using an exception filter (catch ... when (...)), printNot Foundonly when the exception message is404; otherwise a secondcatchprintsOther error. Use top-level statements withtry/catch. Input404prints: Not Found Input500prints: Other error
Expected Output:
Not Found= 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.