Add error framework like in waddrmgr

Add error framework like in waddrmgr