kezhenxu94 commented on a change in pull request #5426:
URL: https://github.com/apache/skywalking/pull/5426#discussion_r483389436



##########
File path: 
apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/context/status/StatusChecker.java
##########
@@ -0,0 +1,61 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.apache.skywalking.apm.agent.core.context.status;
+
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+import java.util.Objects;
+import lombok.AllArgsConstructor;
+import org.apache.skywalking.apm.agent.core.conf.Config;
+
+@AllArgsConstructor
+public enum StatusChecker {
+
+    /**
+     * All exceptions will be thought of as error status.
+     */
+    OFF(Collections.singletonList(new OffExceptionCheckStrategy())),
+
+    /**
+     * If a exception is listed in 
org.apache.skywalking.apm.agent.core.conf.Config.StatusCheck#IGNORED_EXCEPTIONS 
or
+     * tagged with org.apache.skywalking.apm.toolkit.trace.IgnoredException, 
the exception will not be thought as an
+     * error status, also affects its subclasses.
+     */
+    HIERARCHY_MATCH(Arrays.asList(
+        new HierarchyMatchExceptionCheckStrategy(),
+        new AnnotationMatchExceptionCheckStrategy()
+    ));
+
+    private final List<ExceptionCheckStrategy> strategies;
+
+    public boolean checkStatus(Throwable e) {
+        int maxDepth = Config.StatusCheck.MAX_RECURSIVE_DEPTH;
+        boolean isError = true;
+        while (isError && Objects.nonNull(e) && maxDepth-- != 0) {

Review comment:
       ```suggestion
           while (isError && Objects.nonNull(e) && maxDepth-- > 0) {
   ```
   
   in case the user set `maxDepth = -1`




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to