use exception to handle errors, instead of print()