Challenge: Secure Exception Handling
Opgave
Swipe to start coding
Write a function that securely handles exceptions when dividing two numbers. The function must only catch specific exceptions and must not reveal any internal error details in its return value.
- If division is successful, return the result.
- If a
ZeroDivisionErrororTypeErroroccurs, return the string "An error occurred. Please check your input.". - Do not return or expose any exception messages or stack traces.
Løsning
Var alt klart?
Tak for dine kommentarer!
Sektion 1. Kapitel 6
single
Spørg AI
Spørg AI
Spørg om hvad som helst eller prøv et af de foreslåede spørgsmål for at starte vores chat
Awesome!
Completion rate improved to 5.56
Challenge: Secure Exception Handling
Stryg for at vise menuen
Opgave
Swipe to start coding
Write a function that securely handles exceptions when dividing two numbers. The function must only catch specific exceptions and must not reveal any internal error details in its return value.
- If division is successful, return the result.
- If a
ZeroDivisionErrororTypeErroroccurs, return the string "An error occurred. Please check your input.". - Do not return or expose any exception messages or stack traces.
Løsning
Var alt klart?
Tak for dine kommentarer!
Sektion 1. Kapitel 6
single