wrap result and error with a common json format