Add proper error handling in deck & input & nettest & policy

* Refactoring of handler related code