Errors and exceptions
1.[3p] What does a stack trace tell you?
What does a stack trace tell you?
2.[3p] Match each error kind to what causes it.
Match each error kind to what causes it.
ReferenceError
TypeError
RangeError
SyntaxError
text that is not a valid program, including malformed JSON
a name that does not exist, usually a typo
a value outside an allowed range, or a recursion with no reachable base case
a value that is not the kind the operation needs
Show the answer
ReferenceError: a name that does not exist, usually a typo TypeError: a value that is not the kind the operation needs RangeError: a value outside an allowed range, or a recursion with no reachable base case SyntaxError: text that is not a valid program, including malformed JSON
3.[3p] Put the frames of a stack trace in the order they are printed, from top to bottom.
Put the frames of a stack trace in the order they are printed, from top to bottom.
The function that called the one that failed
The function where execution stopped
The top level line that started everything
Show the answer
c, a, b
4.[3p] Why is catch (err) { } with an empty body worse than not catching at all?
Why is catch (err) { } with an empty body worse than not catching at all?
5.[2p] finally runs even when the try block exits through a return.
finally runs even when the try block exits through a return.
6.[2p] throw "oops" is legal. Why throw new Error("oops") instead?
throw "oops" is legal. Why throw new Error("oops") instead?
7.[3p] Which of these are reasons to validate input at the edge of a program rather than in every function?
Which of these are reasons to validate input at the edge of a program rather than in every function?
Select all that apply
8.[2p] Which grade of wrongness produces no message of any kind? Write one word.
Which grade of wrongness produces no message of any kind? Write one word.
9.[2p] A syntax error is reported at line 60, but the file looks correct there. Where is the mistake most likely to be?
A syntax error is reported at line 60, but the file looks correct there. Where is the mistake most likely to be?