refactor handling of json errors