should probably not throw error and return error formatted json