Android Studio IDE: Break on Exception

后端 未结 3 759
-上瘾入骨i
-上瘾入骨i 2020-11-29 16:50

It seems my Android Studio does not want to break on any exception by default. Enabling break on \"Any Exception\" starts breaking within actual JDE libraries. Is there any

3条回答
  •  抹茶落季
    2020-11-29 17:44

    To break on all exceptions in your code and other exceptions if uncaught:

    This methods filters out the exception types that the runtime throws during normal operation (not very exceptional, are they?). It doesn't use the class filter, since it would filter out too much; bugs in your code often cause runtime classes to throw exceptions (e.g. accessing an array list past the end).

    1. Enable Java Exception BreakPoints / Any exception for uncaught exceptions only.

    2. Add a new Java Exception BreakPoint for the Exception (java.lang) class for caught and uncaught exceptions. Enable Condition and set it to this:

          !(this instanceof java.lang.ClassNotFoundException || this instanceof android.system.ErrnoException || this instanceof java.io.FileNotFoundException || this instanceof javax.net.ssl.SSLHandshakeException || this instanceof javax.net.ssl.SSLPeerUnverifiedException || this instanceof android.system.GaiException || this instanceof java.net.SocketTimeoutException || this instanceof java.net.SocketException || this instanceof java.security.NoSuchAlgorithmException)
      

    Add to the exclusion list in the condition any other non-exceptional exceptions you encounter. (BTW, using java.lang.Exception is a way of effectively getting a second "Any exception" entry.)

提交回复
热议问题