Class BenchmarkException

All Implemented Interfaces:
Serializable

public class BenchmarkException extends TestException
Benchmark Exception - Exception thrown during benchmark execution 基准测试异常 - 基准测试执行期间抛出的异常

This exception is thrown when benchmark execution fails.

当基准测试执行失败时抛出此异常。

Features | 主要功能:

  • Benchmark execution failure reporting - 基准测试执行失败报告
  • Benchmark timeout reporting - 基准测试超时报告
  • Factory methods for common benchmark errors - 常见基准测试错误的工厂方法

Usage Examples | 使用示例:

throw BenchmarkException.executionFailed("sortBenchmark", cause);
throw BenchmarkException.timeout("sortBenchmark", 30000);

Security | 安全性:

  • Thread-safe: Yes (immutable after construction) - 线程安全: 是(构造后不可变)
  • Null-safe: Yes - 空值安全: 是
Since:
JDK 25, opencode-base-test V1.0.0
Author:
Leon Soo www.LeonSoo.com
See Also:
  • Constructor Details

    • BenchmarkException

      public BenchmarkException(TestErrorCode errorCode)
      Creates benchmark exception with error code. 使用错误码创建基准测试异常。
      Parameters:
      errorCode - the error code | 错误码
    • BenchmarkException

      public BenchmarkException(TestErrorCode errorCode, String detail)
      Creates benchmark exception with error code and detail. 使用错误码和详情创建基准测试异常。
      Parameters:
      errorCode - the error code | 错误码
      detail - the detail message | 详细消息
    • BenchmarkException

      public BenchmarkException(String message)
      Creates benchmark exception with message. 使用消息创建基准测试异常。
      Parameters:
      message - the message | 消息
    • BenchmarkException

      public BenchmarkException(String message, Throwable cause)
      Creates benchmark exception with message and cause. 使用消息和原因创建基准测试异常。
      Parameters:
      message - the message | 消息
      cause - the cause | 原因
  • Method Details

    • executionFailed

      public static BenchmarkException executionFailed(String benchmarkName, Throwable cause)
      Creates exception for benchmark execution failure. 为基准测试执行失败创建异常。
      Parameters:
      benchmarkName - the benchmark name | 基准测试名称
      cause - the cause | 原因
      Returns:
      the exception | 异常
    • timeout

      public static BenchmarkException timeout(String benchmarkName, long timeoutMs)
      Creates exception for benchmark timeout. 为基准测试超时创建异常。
      Parameters:
      benchmarkName - the benchmark name | 基准测试名称
      timeoutMs - the timeout in milliseconds | 超时毫秒数
      Returns:
      the exception | 异常