Fix error handling in AddHandler

Added correct return values so that errors can be handled.