Osio 3. Luku 6
single
Challenge: 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
namefield is present and not empty, and that theagefield is an integer between 0 and 120. - If validation fails, throw a
DataValidationExceptionwith a descriptive message. - In the
importDatafunction, catch anyDataValidationExceptionand throw aDataImportExceptionthat includes the original validation error message. - In the main processing loop, catch
DataImportExceptionand log the error message using thelogErrorfunction. - If data passes validation, return a string in the format
"Imported: {name} ({age})".
Ratkaisu
Oliko kaikki selvää?
Kiitos palautteestasi!
Osio 3. Luku 6
single
Kysy tekoälyä
Kysy tekoälyä
Kysy mitä tahansa tai kokeile jotakin ehdotetuista kysymyksistä aloittaaksesi keskustelumme