Use exceptions rather than passing magic values