com.redhat.lightblue.util.Error类的使用及代码示例

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

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

Error介绍

[英]Error object. Maintains an error code, message, and context of the error. The context works as a stack of context information that can be passed to the client as an indicator of where the error happened. The error object also provides static APIs that keep the execution context for the current thread.
[中]错误对象。维护错误代码、消息和错误上下文。上下文作为上下文信息的堆栈工作,可以作为错误发生位置的指示器传递给客户端。error对象还提供了静态API,用于保存当前线程的执行上下文。

代码示例

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

public FieldTreeNode resolve(Path p) {
  Error.push(name);
  try {
    return fields.resolve(p);
  } catch (Error e) {
    // rethrow lightblue error
    throw e;
  } catch (Exception e) {
    // throw new Error (preserves current error context)
    LOGGER.error(e.getMessage(), e);
    throw Error.get(MetadataConstants.ERR_ILL_FORMED_METADATA, e.getMessage());
  } finally {
    Error.pop();
  }
}

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

@Override
public String getMessage() {
  return this.toString();
}

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

@Override
public String toString() {
  return toJson().toString();
}

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

/**
 * Constructs a new error object by pushing the given context on top of the
 * current context
 */
public static Error get(String ctx, String errorCode, String msg) {
  push(ctx);
  try {
    return new Error(THREAD_CONTEXT.get(), errorCode, msg);
  } finally {
    pop();
  }
}

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

public void convertPropertyParser(T object, Map<String, Object> properties) {
  Error.push("convertPropertyParser");
  try {
    for (Entry entry : properties.entrySet()) {
      String key = (String) entry.getKey();
      PropertyParser p = extensions.getPropertyParser(key);
      if (p != null) {
        p.convert(this, object, entry.getValue());
      }
    }
  } finally {
    Error.pop();
  }
}

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

public static MetadataStatus statusFromString(String status) {
  switch (status) {
    case STR_ACTIVE:
      return MetadataStatus.ACTIVE;
    case STR_DEPRECATED:
      return MetadataStatus.DEPRECATED;
    case STR_DISABLED:
      return MetadataStatus.DISABLED;
    default:
      throw Error.get(MetadataConstants.ERR_PARSE_INVALID_STATUS, status);
  }
}

代码示例来源: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-metadata

/**
 * Builds a composite metadata rooted at the given entity metadata.
 */
public static CompositeMetadata buildCompositeMetadata(EntityMetadata root,
                            GetMetadata gmd) {
  LOGGER.debug("enter buildCompositeMetadata");
  Error.push("compositeMetadata");
  try {
    CompositeMetadata cmd = buildCompositeMetadata(root, gmd, new Path(), null, new MutablePath());
    return cmd;
  } finally {
    LOGGER.debug("end buildCompositeMetadata");
    Error.pop();
  }
}

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

/**
 * Constructs a new error object by pushing the given context on top of the
 * current context
 */
public static Error get(String ctx, String errorCode, String msg) {
  push(ctx);
  try {
    return new Error(THREAD_CONTEXT.get(), errorCode, msg);
  } finally {
    pop();
  }
}

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

public FieldTreeNode resolve(Path p) {
  Error.push(name);
  try {
    return fields.resolve(p);
  } catch (Error e) {
    // rethrow lightblue error
    throw e;
  } catch (Exception e) {
    // throw new Error (preserves current error context)
    LOGGER.error(e.getMessage(), e);
    throw Error.get(MetadataConstants.ERR_ILL_FORMED_METADATA, e.getMessage());
  } finally {
    Error.pop();
  }
}

代码示例来源: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: lightblue-platform/lightblue-core

/**
 * Builds a composite metadata rooted at the given entity metadata.
 */
public static CompositeMetadata buildCompositeMetadata(EntityMetadata root,
                            GetMetadata gmd) {
  LOGGER.debug("enter buildCompositeMetadata");
  Error.push("compositeMetadata");
  try {
    CompositeMetadata cmd = buildCompositeMetadata(root, gmd, new Path(), null, new MutablePath());
    return cmd;
  } finally {
    LOGGER.debug("end buildCompositeMetadata");
    Error.pop();
  }
}

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

/**
 * Constructs a new error object by pushing the given context on top of the
 * current context
 */
public static Error get(String ctx, String errorCode, String msg) {
  push(ctx);
  try {
    Error x = new Error(THREAD_CONTEXT.get(), errorCode, msg);
    return x;
  } finally {
    pop();
  }
}

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

@Override
public String getMessage() {
  return this.toString();
}

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

@Override
public String toString() {
  return toJson().toString();
}

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

public FieldTreeNode resolve(Path p) {
  Error.push(name);
  try {
    return fields.resolve(p);
  } catch (Error e) {
    // rethrow lightblue error
    throw e;
  } catch (Exception e) {
    // throw new Error (preserves current error context)
    LOGGER.error(e.getMessage(), e);
    throw Error.get(MetadataConstants.ERR_ILL_FORMED_METADATA, e.getMessage());
  } finally {
    Error.pop();
  }
}

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

/**
 * Helper that gets a new Error with msg set to the stack trace of the given
 * Throwable.
 */
public static Error get(String errorCode, Throwable msg) {
  StringWriter sw = new StringWriter();
  PrintWriter pw = new PrintWriter(sw);
  msg.printStackTrace(pw);
  return get(errorCode, sw.toString());
}

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

@Override
public EntityInfo getEntityInfo(String entityName) {
  if (entityName == null || entityName.length() == 0) {
    throw new IllegalArgumentException(LITERAL_ENTITY_NAME);
  }
  Error.push("getEntityInfo(" + entityName + ")");
  try {
    BasicDBObject query = new BasicDBObject(LITERAL_ID, entityName + BSONParser.DELIMITER_ID);
    DBObject ei = collection.findOne(query);
    if (ei != null) {
      return mdParser.parseEntityInfo(ei);
    } else {
      return null;
    }
  } catch (Error e) {
    // rethrow lightblue error
    throw e;
  } catch (Exception e) {
    throw analyzeException(e, MetadataConstants.ERR_ILL_FORMED_METADATA);
  } finally {
    Error.pop();
  }
}

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

@Override
public String getMessage() {
  return this.toString();
}

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

@Override
public String toString() {
  return toJson().toString();
}

相关文章