• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 2007 ZXing authors
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.google.zxing;
18 
19 /**
20  * The general exception class throw when something goes wrong during decoding of a barcode.
21  * This includes, but is not limited to, failing checksums / error correction algorithms, being
22  * unable to locate finder timing patterns, and so on.
23  *
24  * @author Sean Owen
25  */
26 public abstract class ReaderException extends Exception {
27 
28   // disable stack traces when not running inside test units
29   protected static boolean isStackTrace =
30       System.getProperty("surefire.test.class.path") != null;
31   protected static final StackTraceElement[] NO_TRACE = new StackTraceElement[0];
32 
ReaderException()33   ReaderException() {
34     // do nothing
35   }
36 
ReaderException(Throwable cause)37   ReaderException(Throwable cause) {
38     super(cause);
39   }
40 
41   // Prevent stack traces from being taken
42   @Override
fillInStackTrace()43   public final synchronized Throwable fillInStackTrace() {
44     return null;
45   }
46 
47   /**
48    * For testing only. Controls whether library exception classes include stack traces or not.
49    * Defaults to false, unless running in the project's unit testing harness.
50    *
51    * @param enabled if true, enables stack traces in library exception classes
52    * @since 3.5.0
53    */
setStackTrace(boolean enabled)54   public static void setStackTrace(boolean enabled) {
55     isStackTrace = enabled;
56   }
57 
58 }
59