Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Oppiskele Challenge: Chain Exceptions for Better Debugging | Custom Exceptions and Advanced Handling
PHP Error Handling and Exceptions
Osio 2. Luku 6
single

single

bookChallenge: Chain Exceptions for Better Debugging

Pyyhkäise näyttääksesi valikon

Tehtävä

Swipe to start coding

Practice chaining exceptions to preserve error context in a multi-step data processing script. Each step may throw its own custom exception if it fails. You must chain exceptions so that if a later step fails, the original exception(s) are not lost, and the full context is available when catching the error.

  • Call processStepOne, processStepTwo, and processStepThree in order, passing the output of one as the input to the next.
  • If processStepOne throws an exception, throw a new generic Exception with message "Processing failed at step one" and chain the original exception.
  • If processStepTwo throws an exception, throw a new generic Exception with message "Processing failed at step two" and chain the original exception.
  • If processStepThree throws an exception, throw a new generic Exception with message "Processing failed at step three" and chain the original exception.
  • If all steps succeed, return the final result.

Ratkaisu

Switch to desktopVaihda työpöytään todellista harjoitusta vartenJatka siitä, missä olet käyttämällä jotakin alla olevista vaihtoehdoista
Oliko kaikki selvää?

Miten voimme parantaa sitä?

Kiitos palautteestasi!

Osio 2. Luku 6
single

single

Kysy tekoälyä

expand

Kysy tekoälyä

ChatGPT

Kysy mitä tahansa tai kokeile jotakin ehdotetuista kysymyksistä aloittaaksesi keskustelumme

some-alt