Bifalgorithm post · Computer science one · Creating Custom Exceptions
How can a try-catch statement handle an exception from readNumber()?
How can a try-catch statement handle an exception from readNumber()? (Computer science one · Creating Custom Exceptions) — "Elsewhere in the code, we can surro…
Ideas in this flowchart
- Gestion d'une exception de readNumber() avec try-catch
- Un appel à readNumber() est entouré d'une instruction try-catch
- Le bloc try appelle readNumber()
- Le bloc catch traite l'exception Exception $e
- Un message d'erreur est affiché sur la sortie standard
- Le programme se termine avec le statut 1
- $e->getMessage() affiche le message associé à la création de l'exception
- Dans cet exemple, le message est « Invalid input! »
- La décision de conception considère cette erreur comme fatale
- Le bloc catch aurait pu traiter l'erreur autrement