Add error handling

This provides basic error handling throughout the system and removes all panics from the framework and packages.

This pull request adds an `error` return value to most functions and methods as well as interfaces, so it most likely breaks api compatibility if you use a function which returns a value.

The test coverage has been lowered by this pull request, but I'm following this pull request up with more interface changes, so after that code hits the dev branch then I will refactor the tests to bring the coverage back up.
:+1:  :)