error-suppression

I miss Visual Basic's “On Error Resume Next” in C#. How should I be handing errors now?

只愿长相守 提交于 2019-12-01 14:51:03
问题 In Visual Basic I wrote just On Error Resume Next in the head of my program and errors were suppressed in the entire project. Here in C# I miss this feature very much. The usual try-catch handling for every single procedure is not only very time-intensive, it brings undesired effects. If an error is encountered, even if handled, the code doesn't continue from the point it occurred. With On Error Resume Next , the code continued from the point of error, skipping just the function call that

Php function argument error suppression, empty() isset() emulation

一个人想着一个人 提交于 2019-12-01 00:19:59
问题 I'm pretty sure the answer to this question is no, but in case there's some PHP guru is it possible to write a function in a way where invalid arguments or non existent variables can be passed in and php will not error without the use of '@' Much like empty and isset do. You can pass in a variable you just made up and it won't error. ex: empty($someBogusVar); // no error myHappyFunction($someBogusVar); // Php warning / notice 回答1: Summing up, the proper answer is no, you shouldn't (see caveat

How to use cppcheck's inline suppression filter option for C++ code?

♀尐吖头ヾ 提交于 2019-11-30 08:06:45
I would like to use Cppcheck for static code analysis of my C++ code. I learned that I can suppress some kind of warnings with --inline-suppr command. However, I can't find what "suppressed_error_id" I should put in the comment: // cppcheck-suppress "suppressed_error_id" According to the cppcheck help: The error id is the id that you want to suppress. The easiest way to get it is to use the --xml command line flag. Copy and paste the id string from the xml output. So run cppcheck against some code that contains the error with the --xml flag, and then look in the generated XML file to find its

How to use cppcheck's inline suppression filter option for C++ code?

不想你离开。 提交于 2019-11-29 11:02:20
问题 I would like to use Cppcheck for static code analysis of my C++ code. I learned that I can suppress some kind of warnings with --inline-suppr command. However, I can't find what "suppressed_error_id" I should put in the comment: // cppcheck-suppress "suppressed_error_id" 回答1: According to the cppcheck help: The error id is the id that you want to suppress. The easiest way to get it is to use the --xml command line flag. Copy and paste the id string from the xml output. So run cppcheck against

suppress shell script error messages

流过昼夜 提交于 2019-11-29 00:21:26
问题 In my shell script I got these lines: rm tempfl.txt rm tempfl2.txt If these do not exist I get the error messages: rm: tempfl2.txt: No such file or directory rm: tempfl.txt: No such file or directory Is there a way to only suppress these messages even though they do not always appear, as the files might exist? 回答1: You have two options: Suppress rm warnings $ rm tempfl.txt 2> /dev/null Redirect script output to /dev/null $ ./myscript.sh 2> /dev/null The latter has a drawback of missing all

What is the use of the @ symbol in PHP?

梦想的初衷 提交于 2019-11-25 22:25:51
问题 I have seen uses of @ in front of certain functions, like the following: $fileHandle = @fopen($fileName, $writeAttributes); What is the use of this symbol? 回答1: It suppresses error messages — see Error Control Operators in the PHP manual. 回答2: It suppresses errors. See Error Control Operators in the manual: PHP supports one error control operator: the at sign (@). When prepended to an expression in PHP, any error messages that might be generated by that expression will be ignored. If you have