fixed example not to just die with exception
included exceptions in mli
moved raise if error into cmd