A simple wrapper for JSON functions to return errors instead of throw