Skip to content

Commit

Permalink
Internal change
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 730829796
  • Loading branch information
DeviceInfra authored and copybara-github committed Feb 25, 2025
1 parent 7bd7e8e commit 8215513
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 198 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ java_library(
"//src/java/com/google/devtools/common/metrics/stability/model:error_id",
"//src/java/com/google/devtools/common/metrics/stability/util:error_id_formatter",
"//src/java/com/google/wireless/qa/mobileharness/shared:exception",
"//src/java/com/google/wireless/qa/mobileharness/shared/constant:error_code",
"@maven//:com_google_code_findbugs_jsr305",
"@maven//:com_google_errorprone_error_prone_annotations",
"@maven//:com_google_guava_guava",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
package com.google.devtools.mobileharness.api.model.error;

import com.google.devtools.common.metrics.stability.model.ErrorIdProvider;
import com.google.wireless.qa.mobileharness.shared.constant.ErrorCode;
import javax.annotation.Nullable;

/** Base class of all Mobile Harness exceptions. */
Expand Down Expand Up @@ -50,12 +49,7 @@ public MobileHarnessException(ErrorId errorId, String message, @Nullable Throwab
@Nullable Throwable cause,
boolean addErrorIdToMessage,
boolean clearStackTrace) {
super(
ErrorCode.NEXT_GEN_ERROR,
ErrorType.UNCLASSIFIED_ERROR,
addErrorIdToMessage ? message + getMessageSuffix(errorId) : message,
cause,
false /* don't add cause to message */);
super(addErrorIdToMessage ? message + getMessageSuffix(errorId) : message, cause);
this.errorId = errorId;
if (clearStackTrace) {
setStackTrace(EMPTY_STACK_TRACE);
Expand All @@ -74,50 +68,6 @@ public String toString() {
return message == null ? classSimpleName : classSimpleName + ": " + message;
}

/**
* {@inheritDoc}
*
* @deprecated Please use {@link #getErrorId()}.code()
*/
@Override
@Deprecated
public int getErrorCode() {
return errorId.code();
}

/**
* {@inheritDoc}
*
* <p>@deprecated Please use {@link #getErrorId()}.name()
*/
@Override
@Deprecated
public String getErrorName() {
return errorId.name();
}

/**
* {@inheritDoc}
*
* <p>@deprecated Please use {@link #getErrorId()}.type()
*/
@Override
@Deprecated
public ErrorType getErrorType() {
switch (errorId.type()) {
case INFRA_ISSUE:
case DEPENDENCY_ISSUE:
return ErrorType.INFRA_ERROR;
case CUSTOMER_ISSUE:
return ErrorType.USERS_FAILURE;
case UNCLASSIFIED:
case UNDETERMINED:
case UNRECOGNIZED:
break;
}
return ErrorType.UNCLASSIFIED_ERROR;
}

private static String getMessageSuffix(ErrorId errorId) {
return " " + errorId;
}
Expand Down
5 changes: 0 additions & 5 deletions src/java/com/google/wireless/qa/mobileharness/shared/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,6 @@ package(
java_library(
name = "exception",
srcs = ["MobileHarnessException.java"],
deps = [
"//src/java/com/google/wireless/qa/mobileharness/shared/constant:error_code",
"@maven//:com_google_code_findbugs_jsr305",
"@maven//:com_google_guava_guava",
],
)

java_library(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,148 +16,12 @@

package com.google.wireless.qa.mobileharness.shared;

import com.google.wireless.qa.mobileharness.shared.constant.ErrorCode;

/**
* Deprecated. Use {@link com.google.devtools.mobileharness.api.model.error.MobileHarnessException}
* or {@link com.google.devtools.mobileharness.api.model.error.MobileHarnessExceptions} instead.
*/
/** TODO: Remove this class after all the references in catch clauses are removed. */
@Deprecated
public class MobileHarnessException extends Exception {

/**
* Deprecated. Use {@link com.google.devtools.mobileharness.api.model.proto.Error.ErrorType}
* instead.
*/
@Deprecated
public enum ErrorType {
// Default type, job/test result is very likely ERROR.
UNCLASSIFIED_ERROR,
// Errors caused by MH infrastructure, job/test result is very likely INFRA_ERROR.
INFRA_ERROR,
// Errors caused by users, job/test result is very likely FAILED.
USERS_FAILURE;
}

private final ErrorCode errorCode;

private volatile ErrorType errorType;

/**
* @deprecated Please create a new {@link
* com.google.devtools.mobileharness.api.model.error.MobileHarnessException} instead.
*/
@Deprecated
public MobileHarnessException(ErrorCode errorCode, ErrorType errorType, String message) {
super(message);
this.errorCode = errorCode;
this.errorType = errorType;
}

/**
* @deprecated Please create a new {@link
* com.google.devtools.mobileharness.api.model.error.MobileHarnessException} instead.
*/
@Deprecated
public MobileHarnessException(ErrorCode errorCode, String message) {
this(errorCode, ErrorType.UNCLASSIFIED_ERROR, message);
}

/**
* @deprecated Please create a new {@link
* com.google.devtools.mobileharness.api.model.error.MobileHarnessException} instead.
*/
@Deprecated
public MobileHarnessException(int errorCode, String message) {
this(ErrorCode.enumOf(errorCode), message);
}

/**
* @deprecated Please create a new {@link
* com.google.devtools.mobileharness.api.model.error.MobileHarnessException} instead.
*/
@Deprecated
public MobileHarnessException(
ErrorCode errorCode, ErrorType errorType, String errorDetail, Throwable cause) {
this(errorCode, errorType, errorDetail, cause, /* addCauseToMessage= */ true);
}

/**
* @deprecated Please create a new {@link
* com.google.devtools.mobileharness.api.model.error.MobileHarnessException} instead.
*/
@Deprecated
public MobileHarnessException(
ErrorCode errorCode,
ErrorType errorType,
String errorDetail,
Throwable cause,
boolean addCauseToMessage) {
super(
errorDetail
+ (cause == null || !addCauseToMessage
? ""
: ": "
+ cause.getClass().getSimpleName()
+ (cause.getMessage() == null ? "" : ": " + cause.getMessage())),
cause);
this.errorCode = errorCode;
this.errorType = errorType;
}

/**
* @deprecated Please create a new {@link
* com.google.devtools.mobileharness.api.model.error.MobileHarnessException} instead.
*/
@Deprecated
public MobileHarnessException(ErrorCode errorCode, String errorDetail, Throwable cause) {
this(errorCode, ErrorType.UNCLASSIFIED_ERROR, errorDetail, cause);
}

@SuppressWarnings("unused")
@Deprecated
private MobileHarnessException() {
this(ErrorCode.UNKNOWN, "");
}

/**
* @deprecated Use {@link
* com.google.devtools.mobileharness.api.model.error.MobileHarnessException#getErrorId()#getErrorCode()}
* instead.
*/
@Deprecated
public int getErrorCode() {
return errorCode.code();
}

/**
* @deprecated Use {@link
* com.google.devtools.mobileharness.api.model.error.MobileHarnessException#getErrorId()#getErrorName()}
* instead.
*/
@Deprecated
public String getErrorName() {
return errorCode.name();
}

/**
* We are migrating MobileHarnessException to the new version in
* jcg/devtools/mobileharness/api/model/error. Will use the new ErrorId to replace the ErrorCode
* enums. Before fully migrated, please use {@link #getErrorCode()}, {@link #getErrorName()},
* {@link #getErrorType()} when you are still using this old MobileHarnessException, and avoid of
* the new ErrorIds.
*/
@Deprecated
public ErrorCode getErrorCodeEnum() {
return errorCode;
}

/**
* @deprecated Use {@link
* com.google.devtools.mobileharness.api.model.error.MobileHarnessException#getErrorId()#getErrorType()}
* instead.
*/
@Deprecated
public ErrorType getErrorType() {
return errorType;
/** Can only be called by the new MobileHarnessException constructor. */
protected MobileHarnessException(String message, Throwable cause) {
super(message, cause);
}
}

0 comments on commit 8215513

Please sign in to comment.