error-suppression

PHP alias @ function

馋奶兔 提交于 2020-01-14 10:13:10
问题 I'm new to PHP and I'm confused seeing some examples calling a function with a @ prefix like @mysql_ping(). What is it for? Googling / searching is not much of a help since @ gets discarded and 'alias' is not good enough keyword. 回答1: @ suppresses errors, warnings and notices. You can use it for good purpose if you complement it with a custom error handler or with due check of $php_errormsg variable so you can handle errors properly. In my experience, this proper usage is not seen very much

PHP notice suppression; only certain circumstances/methods

左心房为你撑大大i 提交于 2020-01-13 12:07:11
问题 tl;dr - Is there an effective way to manage the error reporting level of PHP when working in a very strict environment, given certain processes would be made easier with a less strict level? Alright; first off, I don't believe "error suppression" is a solution. I ( am reasonably certain that I ) have never used the @ error suppression operator, and have no intention of doing so. I take advantage of set_error_handler() and ErrorException ( or some derivation of ) and I develop in an error

PHP notice suppression; only certain circumstances/methods

痴心易碎 提交于 2020-01-13 12:03:29
问题 tl;dr - Is there an effective way to manage the error reporting level of PHP when working in a very strict environment, given certain processes would be made easier with a less strict level? Alright; first off, I don't believe "error suppression" is a solution. I ( am reasonably certain that I ) have never used the @ error suppression operator, and have no intention of doing so. I take advantage of set_error_handler() and ErrorException ( or some derivation of ) and I develop in an error

Using @ (at sign) in PHP Laravel strings

核能气质少年 提交于 2020-01-06 02:44:21
问题 I have the below code in my app. The problem is the @ (at sign). When it's there, I get syntax highlighting and errors as if the string doesn't end. When remove it, the page works fine (minus the action not existing). I've tried escaping the @ and that doesn't work. I've also tried double quotes, but that doesn't work either. How can I escape @? I could use the route function and avoid the @ entirely but I feel that the action function is far more clear in terms of what it's doing so I'd

R tryCatch handling one kind of error

旧时模样 提交于 2019-12-24 15:24:09
问题 I wondering it is the way to check in tryCatch function kind of errors or warnings like in Java for example. try { driver.findElement(By.xpath(locator)).click(); result= true; } catch (Exception e) { if(e.getMessage().contains("is not clickable at point")) { System.out.println(driver.findElement(By.xpath(locator)).getAttribute("name")+" are not clicable"); } else { System.err.println(e.getMessage()); } } finally { break; } In R I only find solution for handling all error in one ways, example

PHP error suppression is being ignored

荒凉一梦 提交于 2019-12-23 13:38:09
问题 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 the linux server hosting our websites; the problem there being that deprecated functions and strict standards recommendations will very quickly fill up error log files for over 170 websites. The errors are mostly due to small things like functions

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

你离开我真会死。 提交于 2019-12-23 08:53:17
问题 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 { $value = null; } I want to know, before spreading the usage pattern. 回答1: The @ operator suppresses error messages, and using it potentially sets up your code for other errors and unexpected behavior that end up hard to track down. Thus it's most

Check Android Permissions in a Method

不羁岁月 提交于 2019-12-21 06:58:09
问题 here is my code and it works perfectly fine . if (ActivityCompat.checkSelfPermission(activity, Manifest.permission.ACCESS_FINE_LOCATION) == PackageManager.PERMISSION_GRANTED || ActivityCompat.checkSelfPermission(activity, Manifest.permission.ACCESS_COARSE_LOCATION) == PackageManager.PERMISSION_GRANTED) { mMap.setMyLocationEnabled(true); } But I don't like such a big code on every check, and want to delegate it to a method in my utility class. if (Utils.hasMapLocationPermissions(getActivity())

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

扶醉桌前 提交于 2019-12-18 13:32:20
问题 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 ThreadAbortException that the user can just click Continue on. How do I deal with this? I was trying to suppress it like so --> try { Program.splashThread.Abort(); } catch(Exception ex) { } but I have a feeling that is going to get me yelled at here and it doesn't

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

a 夏天 提交于 2019-12-18 08:23:29
问题 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 paths return a value. The problem here is that ThrowHelper will ALWAYS throw an error. It is a static class calling a static method. I understand that I can satisfy the compiler with a silly "return true" after the ThrowHelper call, but that seems like unnecessary