There three kind of catch ... throw method:

AVOID "throw e" !!!catch(Exception e)
            }

The last two method are the same, while the first is different.

The first method will swallow down the exception's StackTrace

Example:

 1AVOID "throw e" !!!class Class1
 2    }

the result is:

at ConsoleApplication1.Class1.throwE()
at ConsoleApplication1.Class1.fun()
at ConsoleApplication1.Class1.Main(String[] args)

if we change the fun() to :

 

 1AVOID "throw e" !!!        void fun()
 2        }

the result is:

at ConsoleApplication1.Class1.fun()
at ConsoleApplication1.Class1.Main(String[] args)

we lose the true throw exception trace, so avoid "throw e"

相关文章:

  • 2021-12-15
  • 2022-12-23
  • 2022-12-23
  • 2021-09-09
  • 2022-12-23
  • 2022-01-16
猜你喜欢
  • 2021-08-27
  • 2022-01-29
  • 2021-07-01
  • 2022-12-23
  • 2022-12-23
  • 2021-10-26
相关资源
相似解决方案