Questions tagged [error-suppression]

Error suppression is the act of preventing an error from surfacing in programming, without addressing it. (Note that suppressing errors is very often considered bad practice.)

Error suppression is the act of preventing an error from making itself apparent, without actually addressing the error itself (the act of addressing the error is ).

Common methods of error suppression are surrounding it with try-catch / try-except statements, redirecting program output, and catching interrupts.

It should be noted that while there are a few circumstances where error suppression may be useful, it is usually looked on as bad practice, as suppressing errors can make debugging the code later a notoriously difficult prospect.

86 questions
633
votes
11 answers

What is the use of the @ symbol in PHP?

I have seen uses of @ in front of certain functions, like the following: $fileHandle = @fopen($fileName, $writeAttributes); What is the use of this symbol?
sv_in
  • 13,929
  • 9
  • 34
  • 55
78
votes
6 answers

How to disable Vim bells sounds?

I am trying to disable the error bells on vim, both visual and audio. However I cannot get them to stay off. I have the following in my vimrc: " Disable annoying beeping set noerrorbells set vb t_vb= That doesn't work, I figured some plugin or…
Lerp
  • 2,957
  • 3
  • 24
  • 43
78
votes
6 answers

How do I suppress shell script error messages?

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…
77
votes
19 answers

Suppress error with @ operator in PHP

In your opinion, is it ever valid to use the @ operator to suppress an error/warning in PHP whereas you may be handling the error? If so, in what circumstances would you use this? Code examples are welcome. Edit: Note to repliers. I'm not looking to…
Mez
  • 24,430
  • 14
  • 71
  • 93
35
votes
4 answers

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

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: //…
Blaise
  • 7,230
  • 6
  • 43
  • 53
29
votes
2 answers

Check Android Permissions in a Method

here is my code and it works perfectly fine. if (ActivityCompat.checkSelfPermission(activity, Manifest.permission.ACCESS_FINE_LOCATION) == PackageManager.PERMISSION_GRANTED || ActivityCompat.checkSelfPermission(activity,…
18
votes
5 answers

Displaying PHP Errors from admin-ajax.php in Wordpress 4.9+

We've got some custom endpoints set up that do various things, which we access via /wp/wp-admin/admin-ajax.php?action=some_action However whenever there is an error as we're developing, such as syntax, logical, fatal etc, we simply get "500 Internal…
owenmelbz
  • 6,180
  • 16
  • 63
  • 113
16
votes
1 answer

Suppress "WebSocket connection to 'xyz' failed"

I've written a web application that uses web-sockets. The idea is that my app tries to auto-connect to recently connected to hosts when it starts up. If it can't establish a connection to any of them, then it directs the user to the connection part…
Kevin Johnson
  • 913
  • 7
  • 24
13
votes
6 answers

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

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…
feedwall
  • 1,473
  • 7
  • 28
  • 48
10
votes
14 answers

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

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…
SeanDowney
  • 17,368
  • 20
  • 81
  • 90
9
votes
6 answers

Is @$array['possibly_missing_key'] an anti-pattern?

Is it OK to use @ when extracting a possibly missing value from a PHP array? Example: $value = @$array['possibly_missing_key']; The intended behavior: if (isset($array['possibly_missing_key'])) { $value = $array['possibly_missing_key']; } else…
Ivo Danihelka
  • 3,382
  • 3
  • 31
  • 27
8
votes
1 answer

Suppress JQ parse error messages in linux

I am looking to parse the json file using JQ utility in bash script , though i am able to parse it correctly , whenever there's invalid json content we get parse error message on the cmd line . So Question is how do we suppress that parse error…
7
votes
3 answers

C#: Any way to suppress compiler errors similar to suppressing warning messages?

I have the following code that generates a compiler error: Boolean IConvertible.ToBoolean(IFormatProvider provider) { ThrowHelper.ThrowInvalidCast(typeof(MyType), typeof(Boolean)); } The compiler is complaining that not all code…
myermian
  • 31,823
  • 24
  • 123
  • 215
6
votes
4 answers

generating suppressions for memory leaks

I want suppress Valgrind's reporting of some "definitely lost" memory by the library I'm using. I have tried valgrind --gen-suppressions=yes ./a but it only prompts for errors such as "conditional jump or move depends on uninitialized value". Is…
Bill
  • 640
  • 2
  • 8
  • 18
6
votes
5 answers

How do I suppress errors in IntelliJ Idea 12

I have lots of errors regarding background images in css. This is because deployment relative paths will be different from my dev environment. These are inconsequential errors that I know I can't do anything about. I would like to turn off checking…
davidjmcclelland
  • 430
  • 9
  • 20
1
2 3 4 5 6