I would say: it depends. If you have hard time and/or memory constraints don“t 
use exceptions (small memory footprint embedded stuff). Besides of that I would 
prefer using exceptions. But do not misuse exceptions (i.e. handling state) 
and/ or catch it to early. If you catch it but you need a raise you should 
check your design . And never ever swallow it silently..

In the specific example I (personally) prefer the invalid-role variant. After 
returning from toRole you can throw the exception there (but also with the 
given (invalid) role-input-string.

Reply via email to