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.

79 questions
598
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,469
  • 9
  • 32
  • 55
72
votes
17 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
  • 22,526
  • 14
  • 67
  • 91
58
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…
52
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,627
  • 3
  • 20
  • 39
28
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
  • 6,244
  • 4
  • 38
  • 53
20
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,…
14
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
  • 873
  • 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,213
  • 6
  • 25
  • 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
  • 16,172
  • 17
  • 77
  • 88
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,274
  • 2
  • 29
  • 26
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
  • 29,999
  • 21
  • 111
  • 199
7
votes
3 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…
Owen
  • 5,225
  • 14
  • 56
  • 102
5
votes
8 answers

How do I suppress a thread.abort() error C#?

I am showing a splash screen on a background thread while my program loads. Once it loads I am aborting the Thread as it's only purpose was to show a Now Loading splash form. My problem is that when aborting a Thread it throws a…
Refracted Paladin
  • 11,636
  • 32
  • 115
  • 224
5
votes
4 answers

Error Suppression @ Not Working

I've been happily using the error suppression operator on my PHP dev setup. But recently have gotten hit with Notices like so: Notice: Uninitialized string offset: 0 in C:\websites\xxx\htdocs\includes\myscript.php on line 35 Line 35: $file_name…
NotoriousWebmaster
  • 2,487
  • 5
  • 31
  • 43
5
votes
1 answer

PHP error suppression is being ignored

My current php.ini file is set to report all errors other than deprecation and strict standards as follows: error_reporting = E_ALL & ~E_STRICT & ~E_DEPRECATED The reason for using this setting is that we urgently need to perform a PHP upgrade on…
William Stewart
  • 801
  • 1
  • 14
  • 27
1
2 3 4 5 6