clean error handling
add error package
Pull deeply nested logic into functions
fix test
Merge pull request #127 from xiangli-cmu/master

clean error handling