Raises any errors that baton has expressed in its output.
        :param baton_out_as_json: the output baton gave as parsed serialization

def _raise_any_errors_given_in_baton_out(baton_out_as_json: List[Dict]):
        """
        Raises any errors that baton has expressed in its output.
        :param baton_out_as_json: the output baton gave as parsed serialization
        """
        if not isinstance(baton_out_as_json, list):
            baton_out_as_json = [baton_out_as_json]

        for baton_item_as_json in baton_out_as_json:
            if BATON_ERROR_PROPERTY in baton_item_as_json:
                error = baton_item_as_json[BATON_ERROR_PROPERTY]
                error_message = error[BATON_ERROR_MESSAGE_KEY]
                error_code = error[BATON_ERROR_CODE_KEY]

                # Working around baton issue: https://github.com/wtsi-npg/baton/issues/155
                if error_code == IRODS_ERROR_USER_FILE_DOES_NOT_EXIST or \
                        (error_code == IRODS_ERROR_CAT_INVALID_ARGUMENT and "Failed to modify permissions" in error_message):
                    raise FileNotFoundError(error_message)
                elif error_code == IRODS_ERROR_CATALOG_ALREADY_HAS_ITEM_BY_THAT_NAME \
                        or error_code == IRODS_ERROR_CAT_SUCCESS_BUT_WITH_NO_INFO:
                    raise KeyError(error_message)
                else:
                    raise RuntimeError(error_message)