function manageErrorMessage(errorContext, errorHolder, message, structured) {
  if (structured) {
    if (errorContext === "document") {
      if (!errorHolder.documentScope) {
        errorHolder.documentScope = [];
      }

      errorHolder.documentScope.push(message);
    } else {
      if (!errorHolder.fieldScope) {
        errorHolder.fieldScope = {};
      }

      let pointer = errorHolder.fieldScope;

      for (let i = 0; i < errorContext.length; i++) {
        if (!pointer.children) {
          pointer.children = {};
        }

        if (!has(pointer.children, errorContext[i])) {
          pointer.children[errorContext[i]] = {};
        }
        pointer = pointer.children[errorContext[i]];
      }

      if (!has(pointer, "messages")) {
        pointer.messages = [];
      }

      pointer.messages.push(message);
    }
  } else if (errorContext === "document") {
    throw kerror.get("validation", "check", "failed_document", message);
  } else {
    throw kerror.get(
      "validation",
      "check",
      "failed_field",
      errorContext.join("."),
      message,
    );
  }
}
@param {string|string[]} errorContext
@param {string[]|{documentScope:string[], fieldScope: {children: ...*}}} errorHolder
@param {string} message
@param {boolean} structured