在Xcode中,我可以创建一个断点来捕获所有异常(异常断点).然而,这个断点也将在尝试捕获的情况下发射.
我正在使用第三方库,因此try-catch情况是一个事实,而不是一个选项.
有没有办法只处理未捕获的异常,而不是所有异常?
xcode exception-handling breakpoints exception uncaught-exception
在flurry站点中,有时会在事件日志会话中而不是事件中
"未捕获"
正在显示.任何人都可以告诉它意味着什么?是app的任何错误吗?[所有事件都显示在网站上,但在某些会话中显示一两个事件然后未被捕获]
我用各种框架(jsf,Spring,Hibernate)编写了一个web应用程序,我的logger库是Logback和slf4j.
目前我无法在日志文件中显示未捕获的异常(例如NullPointers).
这是我的logBack.xml
<configuration debug="true">
<appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${CATALINA_HOME}/logs/jsfDemo.log</file>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<fileNamePattern>jsfDemo.%d{yyyy-MM-dd}.log.zip</fileNamePattern>
<maxHistory>30</maxHistory>
</rollingPolicy>
<encoder>
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{35} - %msg%n</pattern>
</encoder>
</appender>
<root level="DEBUG">
<appender-ref ref="FILE" />
</root>
</configuration>
Run Code Online (Sandbox Code Playgroud)
当我用uc = null执行这几行代码时
public void nullPointerMethod(UserCredential uc){
LOG.debug(">>login(uc)");
if(uc == null){
throw new NullPointerException();
}else{
//do something
}
LOG.debug("<<login(uc)");
}
Run Code Online (Sandbox Code Playgroud)
在logFile我只看到
>>login(uc)
Run Code Online (Sandbox Code Playgroud)
但是我想看看NullPointer的stackTrace.怎么了?
我在node.js项目中使用pm2(https://github.com/Unitech/pm2).此外,我在Logentries(https://logentries.com)发送应用程序错误日志.
我想知道是否可以从应用程序中记录未捕获的异常(例如,当某些内容失败并且pm2重新启动应用程序时)?我知道使用process.on('uncaughtException')是不好的做法,所以想听听一些建议.
谢谢!
以下是我用于处理/记录Express应用程序中所有可能异常的方法.还有其他方法吗?
处理错误是一个微妙的问题,尤其是在处理Express时.让我们从最简单的场景开始.想象一下,我们的应用程序如下:
console.log(ciao.ciao); // EEERRROOORRR
Run Code Online (Sandbox Code Playgroud)
从控制台启动应用程序,我们得到以下内容:
console.log(ciao.ciao);
^
ReferenceError: ciao is not defined
Run Code Online (Sandbox Code Playgroud)
请注意,在上述情况下,它是un Uncaught Exception的一个示例,因为我们没有执行由于错误而执行的代码.要处理上面的错误,我们可以执行以下操作:
process.on('uncaughtException', function (err) {
console.log('error', ' * we did it, we handled the error * ', err.stack.trim());
process.exit(1);
});
console.log(ciao.ciao); // EEERRROOORRR
Run Code Online (Sandbox Code Playgroud)
如果我们现在启动我们得到的应用程序:
error * we did it, we handled the error * ReferenceError: ciao is not defined
Run Code Online (Sandbox Code Playgroud)
请注意!!! "process.on('uncaughtException'..."将被删除!!!
为了在弃用发生时做好准备,我们最好使用我们最喜欢的记录器的异常处理程序,它是功能强大且超级流行的winston.我们的申请成为:
var winston = require('winston');
var logger = new (winston.Logger)({
transports: [
new (winston.transports.Console)({ handleExceptions: true }),
]
});
console.log(ciao.ciao); // EEERRROOORRR
Run Code Online (Sandbox Code Playgroud)
它的输出如下:
error: …Run Code Online (Sandbox Code Playgroud) 未捕获的异常对主线程和另一个std :: thread的行为有所不同.
这是测试程序
#include <thread>
class XXX{
public:
XXX(){std::fprintf(stderr, "XXX ctor\n");}
~XXX(){std::fprintf(stderr, "XXX dtor\n");}
};
void mytest(int i)
{
XXX xtemp;
throw std::runtime_error("Hello, world!");
}
int main(int argc, char *argv[])
{
if(argc == 1) {
mytest(0);
}else{
std::thread th([&]{mytest(0);});
th.join();
}
}
Run Code Online (Sandbox Code Playgroud)
上面的代码(C++ 11),由GCC 5.4编译运行,没有args
XXX ctor
terminate called after throwing an instance of 'std::runtime_error'
what(): Hello, world!
Aborted (core dumped)
Run Code Online (Sandbox Code Playgroud)
运行1 arg:
XXX ctor
XXX dtor
terminate called after throwing an instance of 'std::runtime_error'
what(): Hello, world!
Aborted …Run Code Online (Sandbox Code Playgroud) 在执行使用 Cucumber 框架编写的 n selenium 自动化脚本时,我收到以下异常
org.openqa.selenium.WebDriverException:
unknown error: Cannot read property 'defaultView' of undefined
Run Code Online (Sandbox Code Playgroud)
以前在 spring 19 之前发布通过的脚本。在 spring 19 脚本失败并显示 ablve 异常之后
public void waitForElementToBeDisplayed(WebElement element) {
driver.manage().timeouts().implicitlyWait(40, TimeUnit.SECONDS);
LOGGER.info("element is " +element);
LOGGER.info(String.format("Waiting for WebElement '%s' to be displayed", element.toString().replaceAll(".*-> ", "").replace("]", "")));
element = new WebDriverWait(driver, 40).until(ExpectedConditions.visibilityOf(element));
Assert.assertTrue(element.isDisplayed());
}
Run Code Online (Sandbox Code Playgroud) selenium defaultview salesforce undefined uncaught-exception
我正在尝试使用AdMob广告在屏幕底部显示广告.
我在build.gradle文件中添加了以下行以获取AdMob sdk:
compile 'com.google.android.gms:play-services-ads:8.4.0'
Run Code Online (Sandbox Code Playgroud)
之后,我在XML中添加了AdView来展示广告:
<com.google.android.gms.ads.AdView
android:id="@+id/ad_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_alignParentBottom="true"
app:adSize="BANNER"
android:layout_gravity="bottom"
app:adUnitId="@string/banner_ad_unit_id" />
Run Code Online (Sandbox Code Playgroud)
现在,我使用ad_view id制作AdView的参考资料,并使用以下代码行构建AdRequest来请求广告:
AdView mAdView = (AdView) findViewById(R.id.ad_view);
final AdRequest adRequest = new AdRequest.Builder()
// .addTestDevice("38C0F116926519A0CBAF1094898921FB")
.build();
if (mAdView != null)
mAdView.loadAd(adRequest);
Run Code Online (Sandbox Code Playgroud)
如果我取消注释addTestDevice功能但是当我尝试显示真实广告时,一切都很完美,我在logcat中收到以下错误:
12-23 17:18:02.234 13226-13226/com.abc.xyz I/Ads: Starting ad request.
12-23 17:18:02.234 13226-13226/com.abc.xyz I/Ads: Use AdRequest.Builder.addTestDevice("38C0F116926519A0CBAF1094898921FB") to get test ads on this device.
12-23 17:18:02.554 13226-13226/com.abc.xyz I/Timeline: Timeline: Activity_idle id: android.os.BinderProxy@42dd86b8 time:83516183
12-23 17:18:05.694 13226-13226/com.abc.xyz D/EgretLoader: EgretLoader(Context context)
12-23 17:18:05.694 13226-13226/com.abc.xyz D/EgretLoader: The …Run Code Online (Sandbox Code Playgroud) 当某些网站或 Web 应用程序中抛出未捕获的异常时,每个浏览器的开发者工具中都会出现错误

例如,在Electron中,如果出现未捕获的异常,开发人员可以设置侦听器并根据错误消息执行我想要的操作:
process.on('uncaughtException', function (error) {
// Handle the error
}
Run Code Online (Sandbox Code Playgroud)
所以,我想知道是否有一种简单的方法可以在 JavaScript 中执行相同的操作。这对于记录和存储用户工作时的常见错误,或者向用户显示发生的情况非常有用,用户可以向开发人员发送反馈。
可以显示类似的东西

有时,如果发生错误,应用程序会处于不稳定状态,所有内容都被冻结,而用户不知道原因。我认为告知错误很重要。
我发现了这个Error JavaScript 对象。它可以手动抛出,但只能在使用try和catch时使用,而不能用于开发人员犯了一些错误的未捕获的异常。
javascript error-handling developer-tools uncaught-exception
我试图获取一个元素并使用 Cypress 类型命令,但收到此错误:ResizeObserver 循环已完成,但未传递通知。这是我的代码:
`get signatureBtn() {
return cy.get('#signature').type('userName')
}`
Run Code Online (Sandbox Code Playgroud)
我在文件中使用以下代码support/e2e.js,但仍然收到错误。
Cypress.on('uncaught:exception', (err, runnable) => {
if (err.message.includes('ResizeObserver loop completed with undelivered notifications.')) {
// ignore the error
return false
}
})
Run Code Online (Sandbox Code Playgroud)
有人可以告诉我为什么我会收到此错误吗?多谢!
javascript ×3
android ×2
node.js ×2
admob ×1
banner ×1
breakpoints ×1
c++ ×1
cypress ×1
defaultview ×1
exception ×1
express ×1
flurry ×1
logback ×1
logentries ×1
pm2 ×1
salesforce ×1
selenium ×1
undefined ×1
winston ×1
xcode ×1