Seção 3. Capítulo 6
single
Challenge: Build a Robust Data Processing Script
Deslize para mostrar o menu
Tarefa
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})".
Solução
Tudo estava claro?
Obrigado pelo seu feedback!
Seção 3. Capítulo 6
single
Pergunte à IA
Pergunte à IA
Pergunte o que quiser ou experimente uma das perguntas sugeridas para iniciar nosso bate-papo