@Nullable static String errorCode(Throwable error) {
    if (error instanceof RpcException) {
      return ERROR_CODE_NUMBER_TO_NAME.get(((RpcException) error).getCode());
    }
    return null;
  }
@Test void errorCodes() {
    assertThat(DubboParser.errorCode(null))
        .isEqualTo(DubboParser.errorCode(new IOException("timeout")))
        .isNull();

    assertThat(DubboParser.errorCode(new RpcException(0)))
        .isEqualTo("UNKNOWN_EXCEPTION");
    assertThat(DubboParser.errorCode(new RpcException(1)))
        .isEqualTo("NETWORK_EXCEPTION");
    assertThat(DubboParser.errorCode(new RpcException(2)))
        .isEqualTo("TIMEOUT_EXCEPTION");
    assertThat(DubboParser.errorCode(new RpcException(3)))
        .isEqualTo("BIZ_EXCEPTION");
    assertThat(DubboParser.errorCode(new RpcException(4)))
        .isEqualTo("FORBIDDEN_EXCEPTION");
    assertThat(DubboParser.errorCode(new RpcException(5)))
        .isEqualTo("SERIALIZATION_EXCEPTION");
    assertThat(DubboParser.errorCode(new RpcException(6)))
        .isEqualTo("NO_INVOKER_AVAILABLE_AFTER_FILTER");
    assertThat(DubboParser.errorCode(new RpcException(7)))
        .isEqualTo("LIMIT_EXCEEDED_EXCEPTION");
    assertThat(DubboParser.errorCode(new RpcException(8)))
        .isEqualTo("TIMEOUT_TERMINATE");
    assertThat(DubboParser.errorCode(new RpcException(9)))
      .isEqualTo("REGISTRY_EXCEPTION");
    assertThat(DubboParser.errorCode(new RpcException(10)))
      .isEqualTo("ROUTER_CACHE_NOT_BUILD");
    assertThat(DubboParser.errorCode(new RpcException(11)))
      .isEqualTo("METHOD_NOT_FOUND");
    assertThat(DubboParser.errorCode(new RpcException(12)))
      .isEqualTo("VALIDATION_EXCEPTION");
    assertThat(DubboParser.errorCode(new RpcException(13)))
      .isEqualTo("AUTHORIZATION_EXCEPTION");
    assertThat(DubboParser.errorCode(new RpcException(14)))
      .isNull();// This test will drift with a new error code name if Dubbo adds one
  }