java.lang.Error类的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(5.3k)|赞(0)|评价(0)|浏览(184)

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

Error介绍

[英]Error is the superclass of all classes that represent unrecoverable errors. When errors are thrown, they should not be caught by application code.
[中]

代码示例

代码示例来源:origin: stackoverflow.com

// or it's a property that can throw an error
Object.defineProperty(window, "myVariable", { 
  get: function() { throw new Error("W00t?"); }, 
  set: undefined 
});
if (myVariable) {
  // Error: W00t?
}

代码示例来源:origin: apache/rocketmq

/**
 * You can also modify the body of this method to customize your error messages.
 * For example, cases like LOOP_DETECTED and INVALID_LEXICAL_STATE are not
 * of end-users concern, so you can return something like :
 * <p/>
 * "Internal Error : Please file a bug report .... "
 * <p/>
 * from this method for such cases in the release version of your parser.
 */
public String getMessage() {
  return super.getMessage();
}

代码示例来源:origin: commons-lang/commons-lang

/**
   * {@inheritDoc}
   */
  public final void printPartialStackTrace(PrintWriter out) {
    super.printStackTrace(out);
  }
}

代码示例来源:origin: stackoverflow.com

if ( !(this instanceof arguments.callee) ) 
 throw new Error("Constructor called as a function");

代码示例来源:origin: stanfordnlp/CoreNLP

/**
 * You can also modify the body of this method to customize your error messages.
 * For example, cases like LOOP_DETECTED and INVALID_LEXICAL_STATE are not
 * of end-users concern, so you can return something like :
 *
 *     "Internal Error : Please file a bug report .... "
 *
 * from this method for such cases in the release version of your parser.
 */
public String getMessage() {
 return super.getMessage();
}

代码示例来源:origin: stackoverflow.com

function stackTrace() {
  var err = new Error();
  return err.stack;
}

代码示例来源:origin: stanfordnlp/CoreNLP

/**
 * You can also modify the body of this method to customize your error messages.
 * For example, cases like LOOP_DETECTED and INVALID_LEXICAL_STATE are not
 * of end-users concern, so you can return something like :
 *
 *     "Internal Error : Please file a bug report .... "
 *
 * from this method for such cases in the release version of your parser.
 */
public String getMessage() {
 return super.getMessage();
}

代码示例来源:origin: netty/netty

@Override
protected void doFinishConnect() throws Exception {
  throw new Error();
}

代码示例来源:origin: apache/zookeeper

/**
 * You can also modify the body of this method to customize your error messages.
 * For example, cases like LOOP_DETECTED and INVALID_LEXICAL_STATE are not
 * of end-users concern, so you can return something like :
 *
 *     "Internal Error : Please file a bug report .... "
 *
 * from this method for such cases in the release version of your parser.
 */
public String getMessage() {
 return super.getMessage();
}

代码示例来源:origin: stackoverflow.com

function assert(condition, message) {
  if (!condition) {
    message = message || "Assertion failed";
    if (typeof Error !== "undefined") {
      throw new Error(message);
    }
    throw message; // Fallback
  }
}

代码示例来源:origin: stanfordnlp/CoreNLP

/**
 * You can also modify the body of this method to customize your error messages.
 * For example, cases like LOOP_DETECTED and INVALID_LEXICAL_STATE are not
 * of end-users concern, so you can return something like :
 *
 *     "Internal Error : Please file a bug report .... "
 *
 * from this method for such cases in the release version of your parser.
 */
public String getMessage() {
 return super.getMessage();
}

代码示例来源:origin: netty/netty

private Component findIt(int offset) {
  for (int low = 0, high = componentCount; low <= high;) {
    int mid = low + high >>> 1;
    Component c = components[mid];
    if (offset >= c.endOffset) {
      low = mid + 1;
    } else if (offset < c.offset) {
      high = mid - 1;
    } else {
      lastAccessed = c;
      return c;
    }
  }
  throw new Error("should not reach here");
}

代码示例来源:origin: stanfordnlp/CoreNLP

/**
 * You can also modify the body of this method to customize your error messages.
 * For example, cases like LOOP_DETECTED and INVALID_LEXICAL_STATE are not
 * of end-users concern, so you can return something like :
 *
 *     "Internal Error : Please file a bug report .... "
 *
 * from this method for such cases in the release version of your parser.
 */
public String getMessage() {
 return super.getMessage();
}

代码示例来源:origin: stackoverflow.com

var stack = new Error().stack
console.log( stack )

代码示例来源:origin: apache/storm

/**
* You can also modify the body of this method to customize your error messages.
* For example, cases like LOOP_DETECTED and INVALID_LEXICAL_STATE are not
* of end-users concern, so you can return something like : 
*
*     "Internal Error : Please file a bug report .... "
*
* from this method for such cases in the release version of your parser.
*/
public String getMessage() {
 return super.getMessage();
}

代码示例来源:origin: netty/netty

private static Level toLevel(InternalLogLevel level) {
    switch (level) {
      case INFO:
        return Level.INFO;
      case DEBUG:
        return Level.DEBUG;
      case WARN:
        return Level.WARN;
      case ERROR:
        return Level.ERROR;
      case TRACE:
        return Level.TRACE;
      default:
        throw new Error();
    }
  }
}

代码示例来源:origin: commons-lang/commons-lang

/**
 * {@inheritDoc}
 */
public String getMessage(int index) {
  if (index == 0) {
    return super.getMessage();
  }
  return delegate.getMessage(index);
}

代码示例来源:origin: netty/netty

static int wrapperOverhead(ZlibWrapper wrapper) {
  int overhead;
  switch (wrapper) {
  case NONE:
    overhead = 0;
    break;
  case ZLIB:
  case ZLIB_OR_NONE:
    overhead = 2;
    break;
  case GZIP:
    overhead = 10;
    break;
  default:
    throw new Error();
  }
  return overhead;
}

代码示例来源:origin: redisson/redisson

@Override
  public String getMessage()
  {
    return String.format("[%s] %s", errorCode.name(), super.getMessage());
  }
}

代码示例来源:origin: netty/netty

static byte[] allocateUninitializedArray(int size) {
  try {
    return (byte[]) ALLOCATE_ARRAY_METHOD.invoke(INTERNAL_UNSAFE, byte.class, size);
  } catch (IllegalAccessException e) {
    throw new Error(e);
  } catch (InvocationTargetException e) {
    throw new Error(e);
  }
}

相关文章