com.redhat.lightblue.util.Error.get()方法的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(6.4k)|赞(0)|评价(0)|浏览(154)

本文整理了Java中com.redhat.lightblue.util.Error.get()方法的一些代码示例,展示了Error.get()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Error.get()方法的具体详情如下:
包路径:com.redhat.lightblue.util.Error
类名称:Error
方法名:get

Error.get介绍

[英]Constructs a new error object using the current context
[中]使用当前上下文构造新的错误对象

代码示例

代码示例来源:origin: lightblue-platform/lightblue-core

/**
 * Helper that gets a new Error with msg set to the message of the given
 * Throwable.
 */
public static Error get(String ctx, String errorCode, Throwable e) {
  LOGGER.error(e.getMessage(), e);
  return get(ctx, errorCode, e.getMessage());
}

代码示例来源:origin: com.redhat.lightblue/lightblue-core-util

/**
 * Helper that gets a new Error with msg set to the message of the given
 * Throwable.
 */
public static Error get(String ctx, String errorCode, Throwable e) {
  LOGGER.error(e.getMessage(), e);
  return get(ctx, errorCode, e.getMessage());
}

代码示例来源:origin: com.redhat.lightblue.mongo/lightblue-mongo-metadata

private static JsonNode toJson(String object) {
    try {
      return JsonUtils.json(object);
    } catch (Exception e) {
      throw Error.get(MetadataConstants.ERR_ILL_FORMED_METADATA, object);
    }
  }
}

代码示例来源:origin: com.redhat.lightblue.mongo/lightblue-mongo-crud

private void convertReferenceFieldToBson(JsonNode node,Path path) {
  if(node instanceof NullNode || node.size()==0)
    return;
  //TODO
  throw Error.get(ERR_CANNOT_TRANSLATE_REFERENCE,path.toString());
}

代码示例来源:origin: lightblue-platform/lightblue-core

@Override
public Object fromJson(JsonNode node) {
  if (node instanceof NullNode) {
    return null;
  } else if (node.isValueNode()) {
    return node.asText();
  } else {
    throw Error.get(NAME, MetadataConstants.ERR_INCOMPATIBLE_VALUE, node.toString());
  }
}

代码示例来源:origin: com.redhat.lightblue/lightblue-core-metadata

/**
 * Returns the single field name contained in the object. If the object
 * contains more fields or no fields, throws an error with the given error
 * code.
 */
private String getSingleFieldName(T object, String errorCode) {
  Set<String> names = getChildNames(object);
  if (names.size() != 1) {
    throw Error.get(errorCode, names.toString());
  }
  return names.iterator().next();
}

代码示例来源:origin: com.redhat.lightblue/lightblue-core-crud

private IndexedFieldScorerData getData(QueryPlanNode node) {
    try {
      return (IndexedFieldScorerData) node.getData();
    } catch (ClassCastException e) {
      throw Error.get(AssocConstants.ERR_INVALID_QUERYPLAN);
    }
  }
}

代码示例来源:origin: com.redhat.lightblue/metadata

@Override
public Object fromJson(JsonNode node) {
  if (node.isValueNode()) {
    return node.bigIntegerValue();
  } else {
    throw Error.get(NAME, MetadataConstants.ERR_INCOMPATIBLE_VALUE, node.toString());
  }
}

代码示例来源:origin: lightblue-platform/lightblue-core

@Override
public Object fromJson(JsonNode node) {
  if (node == null || node instanceof NullNode) {
    return null;
  } else if (node.isValueNode()) {
    try {
      return node.binaryValue();
    } catch (Exception e) {
    }
  }
  throw Error.get(NAME, MetadataConstants.ERR_INCOMPATIBLE_VALUE, node.toString());
}

代码示例来源:origin: com.redhat.lightblue/lightblue-core-metadata

public void addEnum(Enum x) {
  if (enums.containsKey(x.getName())) {
    throw Error.get(MetadataConstants.ERR_DUPLICATE_ENUM, x.getName());
  }
  enums.put(x.getName(), x);
}

代码示例来源:origin: com.redhat.lightblue/metadata

public void addNew(Field f) {
  String name = f.getName();
  if (has(name)) {
    throw Error.get(MetadataConstants.ERR_DUPLICATE_FIELD, name);
  }
  f.setParent(parent);
  fieldMap.put(name, f);
  fields.add(f);
}

代码示例来源:origin: com.redhat.lightblue.mongo/lightblue-mongo-crud

private FieldTreeNode resolve(FieldTreeNode context, Path field) {
  FieldTreeNode node = context.resolve(field);
  if (node == null) {
    throw Error.get(ERR_INVALID_FIELD, field.toString());
  }
  return node;
}

代码示例来源:origin: com.redhat.lightblue/lightblue-core-crud

@Override
  public void checkConstraint(ConstraintValidator validator,
                FieldTreeNode fieldMetadata,
                Path fieldMetadataPath,
                FieldConstraint constraint,
                JsonDoc doc) {
    List<Path> errors = RequiredChecker.getMissingFields(fieldMetadataPath, doc);
    for (Path x : errors) {
      validator.addDocError(Error.get(CrudConstants.ERR_REQUIRED, x.toString()));
    }
  }
}

代码示例来源:origin: com.redhat.lightblue/metadata

private Field parseSimpleField(String name,
                String type) {
  SimpleField field = new SimpleField(name);
  Type t = typeResolver.getType(type);
  if (t == null) {
    throw Error.get(MetadataConstants.ERR_INVALID_TYPE, type);
  }
  field.setType(t);
  return field;
}

代码示例来源:origin: com.redhat.lightblue.mongo/lightblue-mongo

private void handleBulkWriteError(List<BulkWriteError> errors, String operation, List<DocInfo> docs) {
  for (BulkWriteError e : errors) {
    DocInfo doc = docs.get(e.getIndex());
    if (MongoCrudConstants.isDuplicate(e.getCode())) {
      doc.inputDoc.addError(Error.get("update", MongoCrudConstants.ERR_DUPLICATE, e.getMessage()));
    } else {
      doc.inputDoc.addError(Error.get("update", MongoCrudConstants.ERR_SAVE_ERROR, e.getMessage()));
    }
  }
}

代码示例来源:origin: com.redhat.lightblue/metadata

@Override
public FieldTreeNode resolve(Path p, int level) {
  if (p.numSegments() == level) {
    return this;
  } else if (Path.PARENT.equals(p.head(level))) {
    return this.getParent().resolve(p, level + 1);
  } else {
    throw Error.get(MetadataConstants.ERR_INVALID_FIELD_REFERENCE);
  }
}

代码示例来源:origin: lightblue-platform/lightblue-core

/**
 * Resolve the given field, find its metadata. Throw exception if it cannot
 * be resolved.
 */
private FieldTreeNode resolve(Path field) {
  FieldTreeNode fieldNode = ref == null ? root.resolve(field)
      : ref.getElement().resolve(field);
  if (fieldNode == null) {
    throw Error.get(AssocConstants.ERR_CANNOT_FIND_FIELD, field.toString());
  }
  return fieldNode;
}

代码示例来源:origin: lightblue-platform/lightblue-core

@Override
public FieldTreeNode resolve(Path p, int level) {
  if (p.numSegments() == level) {
    return this;
  } else if (Path.PARENT.equals(p.head(level))) {
    return this.getParent().resolve(p, level + 1);
  } if (p.head(level).equals(Path.THIS)) {
    return this.resolve(p,level+1);
  } else {
    throw Error.get(MetadataConstants.ERR_INVALID_FIELD_REFERENCE, p.head(level) + " in " + p.toString());
  }
}

代码示例来源:origin: lightblue-platform/lightblue-core

@Override
public FieldTreeNode resolve(Path p, int level) {
  if (p.numSegments() == level) {
    return this;
  } else if (p.head(level).equals(Path.PARENT)) {
    return this.getParent().getParent().resolve(p, level + 1);
  } else if (p.head(level).equals(Path.THIS)) {
    return this.resolve(p,level+1);
  } else {
    throw Error.get(MetadataConstants.ERR_INVALID_ARRAY_REFERENCE,p.toString());
  }
}

代码示例来源:origin: com.redhat.lightblue/lightblue-core-metadata

/**
 * Checks that the default version on the EntityInfo exists. If no default
 * version is set then has no side effect. If the default version does not
 * exist an error is raised.
 *
 * @param ei
 */
protected final void validateDefaultVersion(EntityInfo ei) {
  if (ei.getDefaultVersion() != null && !checkVersionExists(ei.getName(), ei.getDefaultVersion())) {
    throw com.redhat.lightblue.util.Error.get(MetadataConstants.ERR_INVALID_DEFAULT_VERSION, ei.getName() + ":" + ei.getDefaultVersion());
  }
}

相关文章