• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2023 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 package com.android.adservices.errorlogging;
18 
19 import com.google.auto.value.AutoValue;
20 
21 /**
22  * Class which contains data for AdServices Error logging. This is used by AdServicesErrorReported
23  * atom.
24  */
25 @AutoValue
26 public abstract class AdServicesErrorStats {
27     /** @return error/exception code. */
getErrorCode()28     public abstract int getErrorCode();
29 
30     /** @return name of the PPAPI where the error occurred. */
getPpapiName()31     public abstract int getPpapiName();
32 
33     /** @return name of the class where we catch the exception or log the error. */
getClassName()34     public abstract String getClassName();
35 
36     /** @return name of the method where we catch the exception or log the error. */
getMethodName()37     public abstract String getMethodName();
38 
39     /** @return line number where we catch the exception or log the error. */
getLineNumber()40     public abstract int getLineNumber();
41 
42     /** @return the fully qualified name of the last encountered exception. */
getLastObservedExceptionName()43     public abstract String getLastObservedExceptionName();
44 
45     /** @return builder populating default values */
builder()46     public static AdServicesErrorStats.Builder builder() {
47         return new AutoValue_AdServicesErrorStats.Builder()
48                 .setClassName("")
49                 .setMethodName("")
50                 .setLastObservedExceptionName("")
51                 .setLineNumber(0)
52                 .setPpapiName(0);
53     }
54 
55     /** Builder class for {@link AdServicesErrorStats}. */
56     @AutoValue.Builder
57     public abstract static class Builder {
58         /** Sets error/exception code. */
setErrorCode(int errorCode)59         public abstract AdServicesErrorStats.Builder setErrorCode(int errorCode);
60 
61         /** Sets name of the PPAPI where the error occurred. */
setPpapiName(int ppapiName)62         public abstract AdServicesErrorStats.Builder setPpapiName(int ppapiName);
63 
64         /** Sets name of the class where we catch the exception or log the error. */
setClassName(String className)65         public abstract AdServicesErrorStats.Builder setClassName(String className);
66 
67         /** Sets name of the method where we catch the exception or log the error. */
setMethodName(String methodName)68         public abstract AdServicesErrorStats.Builder setMethodName(String methodName);
69 
70         /** Sets line number where we catch the exception or log the error. */
setLineNumber(int lineNumber)71         public abstract AdServicesErrorStats.Builder setLineNumber(int lineNumber);
72 
73         /** Sets the fully qualified name of the last encountered exception. */
setLastObservedExceptionName( String lastExceptionName)74         public abstract AdServicesErrorStats.Builder setLastObservedExceptionName(
75                 String lastExceptionName);
76 
77         /** build for {@link AdServicesErrorStats}. */
build()78         public abstract AdServicesErrorStats build();
79     }
80 }
81