Seção 2. Capítulo 2
single
Challenge: Implement a Custom Exception
Deslize para mostrar o menu
Tarefa
Swipe to start coding
In this task, you will define a custom exception class and use it to handle invalid user input in a registration form scenario. This will help you practice creating your own exception types and using them to manage errors in a more meaningful way.
- Define a custom exception class named
InvalidRegistrationExceptionthat extends the built-inExceptionclass. - Implement the
validateRegistrationfunction so that it throws anInvalidRegistrationExceptionif the username is empty. - Make the function throw an
InvalidRegistrationExceptionif the password is less than 6 characters long. - If both checks pass, the function should return a success message containing the username.
Solução
Tudo estava claro?
Obrigado pelo seu feedback!
Seção 2. Capítulo 2
single
Pergunte à IA
Pergunte à IA
Pergunte o que quiser ou experimente uma das perguntas sugeridas para iniciar nosso bate-papo