Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Oppiskele Challenge: Build a Robust Data Processing Script | Validation Flows and Safe Execution Patterns
Practice
Projects
Quizzes & Challenges
Visat
Challenges
/
PHP Error Handling and Exceptions
Osio 3. Luku 6
single

single

bookChallenge: Build a Robust Data Processing Script

Pyyhkäise näyttääksesi valikon

Tehtävä

Swipe to start coding

Combine everything you have learned about validation, exceptions, and safe execution to build a robust data processing script. In this challenge, you will process a batch of data rows, validate each entry, and handle any issues gracefully using exceptions and error logging.

  • Validate each data row to ensure the name field is present and not empty, and that the age field is an integer between 0 and 120.
  • If validation fails, throw a DataValidationException with a descriptive message.
  • In the importData function, catch any DataValidationException and throw a DataImportException that includes the original validation error message.
  • In the main processing loop, catch DataImportException and log the error message using the logError function.
  • If data passes validation, return a string in the format "Imported: {name} ({age})".

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 3. Luku 6
single

single

Kysy tekoälyä

expand

Kysy tekoälyä

ChatGPT

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

some-alt