Sezione 3. Capitolo 6
single
Challenge: Build a Robust Data Processing Script
Scorri per mostrare il menu
Compito
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})".
Soluzione
Tutto è chiaro?
Grazie per i tuoi commenti!
Sezione 3. Capitolo 6
single
Chieda ad AI
Chieda ad AI
Chieda pure quello che desidera o provi una delle domande suggerite per iniziare la nostra conversazione