Exercise 2: Why try/catch Catches a 404 With No -ErrorAction Stop — Possible Solution ==================================================================== FUNDAMENTALS 9'S GENERAL RULE ------------------------------ Per Fundamentals 9, most cmdlet errors - a missing file, an unreachable path - are non-terminating by default: PowerShell displays the error and simply continues on to the next statement, which is why try/catch usually does nothing at all unless -ErrorAction Stop is explicitly added to convert that specific error into a terminating one. WHY Invoke-RestMethod IS DIFFERENT ------------------------------ Per this chapter, Invoke-RestMethod (and Invoke-WebRequest) don't follow that same default pattern - any non-2xx HTTP status code, including a 404, is treated as a genuinely terminating error automatically, with no -ErrorAction Stop required anywhere. This is a real, deliberate exception to Fundamentals 9's own general rule, not a violation of it - most cmdlets default to non-terminating, but these two specifically default to terminating for HTTP failures. WHY THIS MATTERS TO REMEMBER ------------------------------ Per this chapter, it's worth remembering specifically because it's the exception rather than the norm - a habit of always adding -ErrorAction Stop "just in case" isn't wrong here, but for Invoke-RestMethod it isn't actually necessary, unlike the vast majority of other cmdlets covered throughout this course. WHY THIS WORKS AS AN ANSWER ------------------------------ It correctly restates Fundamentals 9's own non-terminating-by-default rule, correctly explains that Invoke-RestMethod's HTTP errors are terminating by default as a genuine, deliberate exception to that rule, and correctly frames why this exception is worth remembering rather than assuming it always applies.