Custom exception class that uses instanceof to determine type errors

defines a class BusinessRunTimeException, that inherits RuntimeException. When captured by controller, the result of e instanceof BusinessRunTimeException judgment is returned to false

.

related codes

Business layer throws an exception directly:

  throw new BusinessRunTimeException();

Control layer capture:

    try {
             //
        } catch (Exception e) {
            if (e instanceof BusinessRunTimeException) {
                BusinessRunTimeException b = (BusinessRunTimeException) e;
                //
            } else {
               //
            }
          }
Aug.23,2021

e e.getCause() instanceof

according to the test, there should be a layer of package in some location


WTF, so the question is?


because it is a dubbo project, it handles the exception itself. For more information, please see https://blog.csdn.net/XLee190.

.
Menu