public static boolean isInsufficientPermissionsException(Throwable th) {
Throwable cause = ForceExceptionUtils.getRootCause(th);
if (th instanceof InsufficientPermissionsException || cause instanceof InsufficientPermissionsException) {
return true;
} else if (cause instanceof ApiFault) {
ApiFault apiFaultCause = (ApiFault) cause;
if (Utils.isEqual(StatusCode.INVALID_ACCESS_LEVEL.toString(), apiFaultCause.getExceptionCode().toString())
|| isOrgBasedInsufficientPermissionsException(apiFaultCause)) {
return true;
} else if (Utils.isEqual(StatusCode.INVALID_TYPE.toString(), apiFaultCause.getExceptionCode().toString())
&& Utils.isNotEmpty(apiFaultCause.getExceptionMessage())
&& (apiFaultCause.getExceptionMessage().contains("'" + SoqlEnum.INSTALL_PACKAGE_OBJECT + "'")
|| apiFaultCause.getExceptionMessage().contains("'" + SoqlEnum.DEVELOPMENT_PACKAGE_OBJECT+ "'"))) {
return true;
}
}
else if (Utils.isNotEmpty(cause.getMessage())
&& cause.getMessage().startsWith(FaultCode.INSUFFICIENT_ACCESS.toString())) {