Validate arguments.

Validate arguments and handle errors.
Merge pull request #3 from daniel-star/validate-arguments

Validate arguments.