问题标签 [error-suppression]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
1 回答
511 浏览

php - 抑制 php imagecreatefromjpeg 错误

我有一个处理上传的 jpg 的脚本,无论出于何种原因,一些 jpg 似乎不符合 imagecreatefromjpeg 的任何期望。我怀疑它与全景图像有关,但还没有时间追查它。我准备跳过有缺陷的 jpgs,支持 99% 的工作正常。但是,我似乎无法让我的脚本通过这些小问题之一。每次将这些有缺陷的 jpg 之一上传到文件池中时,我都会收到一条内联错误消息:

错误编号:8

错误描述:imagecreatefromjpeg(): gd-jpeg, libjpeg: 可恢复错误:顺序 JPEG 的 SOS 参数无效

知道这里可能发生了什么吗?我已经做了我能想到的一切来防止错误使这个操作脱轨......然而,我们到了。

单击此处例如 jpg 使一切脱轨

0 投票
1 回答
103 浏览

c# - 找出需要这种抑制的局部变量

我正在使用的 c# 项目打开了“错误警告”,并且它们在代码中有很多抑制。其中包括:

如果我删除抑制,构建将失败。如何找出 c# 代码中的哪个特定标识符导致警告?

0 投票
4 回答
14858 浏览

php - 在 Wordpress 4.9+ 中显示来自 admin-ajax.php 的 PHP 错误

我们已经设置了一些自定义端点来做各种事情,我们通过/wp/wp-admin/admin-ajax.php?action=some_action

但是,每当我们在开发过程中出现错误时,例如语法、逻辑、致命等,我们在浏览器中查看页面时只会收到“500 Internal Server Error”。

网站上的每个其他页面出现错误时,都会向我们提供 PHP 错误,以帮助我们进行调试。

但是,当错误来自该admin-ajax.php区域时,我们必须打开我们的 PHP 日志文件来查看错误——这在积极开发时更加痛苦

wordpress 中是否有禁止在此 URL 命名空间上显示错误的内容?如果是这样,我们如何防止这种情况允许在浏览器上呈现错误?

0 投票
1 回答
908 浏览

c - PC lint 错误 19“无用的声明”

我想了解 PC lint 错误 19“无用声明”的解决方案。我正在使用中断向量表,并使用所需参数调用中断。当我运行 PC lint 时,我遇到如下所示的错误 19,有人可以帮助我吗?

ifndef Int_HandlerIndAddr

#define Int_HandlerIndAddr(Isr, CpuNr, IntNr, Prio) Int_HandlerIndAddr2(Isr, CpuNr, IntNr, Prio)

万一

在同一个文件中的函数调用如下

PC lint 错误消息如下:

0 投票
1 回答
1021 浏览

r - 使用 fitdistrplus 包中的 fitdist() 时抑制错误消息

我正在使用包中的某些功能fitdistrplus作为我正在创建的包的一部分。

我试图防止在运行函数时在控制台中显示任何错误消息,而是希望将错误消息记录在我正在创建的错误日志中。

在大多数情况下,使用tryCatch()使我能够做到这一点。

但特别是对于该fitdist()函数,即使正在将消息写入错误日志(意味着tryCatch()表达式正在运行),我也无法抑制在控制台中打印的错误消息。

我在下面的代码中复制了我的问题。

我想禁止打印此错误消息func_fit()

我已经尝试过以下替代方案:

  1. try()silent = TRUE. 仍然会打印错误消息。
  2. conditionMessage()给出相同的结果。
  3. withCallingHandlers()在某些帖子和线程中已提出建议,但我不确定如何正确实施。
  4. 与函数一起使用invisible()仍然会打印错误。
0 投票
2 回答
425 浏览

python - How to suppress the error message: "Error in `./hubbard.exc': corrupted size vs. prev_size"?

I have a very old program (from the late 80s) written in C++ and I somehow managed to get it running on Ubuntu 16.04 64Bit. Even if it produces an error at the end, the results are okay. Since it seems to be impossible to compile that program nowadays (it makes use of a very old version of the proprietary library NAG) I cant fix the problem in the source code and have to live with the error. I need to run this program in a loop and the error message completely clutters my screen and prevents me from seeing relevant messages. I tried to suppress the message by using calls like ./hubbard.exc 2>/dev/null and variants of it like &>/dev/null, but the error message is still printed to screen. So I conclude, that this error message is neither printed to stdout nor to stderr.

I would be grateful for any help to suppress this error message or for an advise on how to suppres all output of the shell!

In case that it would not be possible to suppress this error message in the shell it would also help me to find a way to run the program from a Python3 script (using subprocess or os.system) without that the error is printed to screen.

The error message Im talking about looks as follows:

0 投票
3 回答
2087 浏览

javascript - 如何比较输入和 JSON 数据

我正在做一个学校项目,我需要在不制作真实数据库的情况下验证一些用户。我的问题是,当我将输入中输入的信息与存储在 JSON 中的信息进行比较时,它会为每个不匹配的选项弹出一个错误。我想要的是将多个错误减少为一个(以防用户名或密码与存储在 JSON 中的信息不匹配)。这是我的 JavaScript:

这是用 JSON 制作的假数据库:

0 投票
1 回答
159 浏览

php - 如何判断 @error 控制操作符是否抑制了错误?

我正在使用的第 3 方库在其代码中使用 @ 错误抑制运算符,这会导致通过 @ 抑制的错误仍然会导致错误输出,因为我使用的是自定义错误处理程序(set_error_handler())

在这个页面它说

如果您使用 set_error_handler() 设置了自定义错误处理函数,那么它仍然会被调用,但是这个自定义错误处理程序可以(并且应该)调用 error_reporting(),当触发错误的调用前面有 @ 时,它将返回 0 .

但是,尚不清楚我如何准确地捕捉到 @ 前面的错误。

我的问题是如何捕获通过@ 抑制的错误?

0 投票
1 回答
44 浏览

php - 处理@抑制的错误的正确方法?

手册中所述,如果错误来自抑制,则调用error_reporting()将返回。但由于我的生产服务器始终设置为(在脚本之上),调用将始终返回到.0@error_reporting(0)error_reporting()0

我如何才能真正捕捉或区分合法错误与被 抑制的错误@

现在我的错误处理程序是这样的:

注意:这与我之前的问题有关

0 投票
2 回答
261 浏览

php - 如何在 PHP 中禁用错误​​抑制“@”运算符?

我有一个鲁莽编写的代码(由以前的开发人员 ofc编写),并且错误抑制运算符“@”被广泛使用。现在我必须调试一个错误,它证明了一个真正的 PITA。

我已经尝试过像设置这样的常客error_reportingdisplay_errors但仍然尊重错误抑制(也许它应该是这样的)。

我也想过使用搜索和替换使用regex,但我保留它以备不时之需。

现在我的问题是,有没有办法可以覆盖错误抑制运算符?