473,405 Members | 2,445 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

Custom error handling

I've created my own function for error handling using set_error_handler().
My problem is that, when using copy() to copy files, I can't suppress
system's error messages. So when I'm trying to copy a file that does not
exist I get two error messages: mine and system's.

I've tried the @ operator with no luck: @copy(...)

Apart from adding extra checks so copy() never returns an error or using
system(), is there a way to replace all error messages with mine?

--
-- Álvaro G. Vicario - Burgos, Spain
-- http://bits.demogracia.com - Mi sitio sobre programación web
-- Don't e-mail me your questions, post them to the group
--
Aug 9 '05 #1
2 1434
Alvaro G Vicario wrote:
I've created my own function for error handling using set_error_handler().
My problem is that, when using copy() to copy files, I can't suppress
system's error messages. So when I'm trying to copy a file that does not
exist I get two error messages: mine and system's.

I've tried the @ operator with no luck: @copy(...)

<snip>

<quote src="http://in.php.net/set_error_handler">
It is important to remember that the standard PHP error handler is
completely bypassed. error_reporting() settings will have no effect and
your error handler will be called regardless - however you are still
able to read the current value of error_reporting and act
appropriately. Of particular note is that this value will be 0 if the
statement that caused the error was prepended by the @ error-control
operator.
</quote>

So, in your callback function, check if the current error_reporting()
level (when the error is triggerred) is 0-- if so, ignore that
error--so that your @ operator will work.

--
<?php echo 'Just another PHP saint'; ?>
Email: rrjanbiah-at-Y!com Blog: http://rajeshanbiah.blogspot.com

Aug 9 '05 #2
*** R. Rajesh Jeba Anbiah wrote/escribió (9 Aug 2005 04:31:47 -0700):
So, in your callback function, check if the current error_reporting()
level (when the error is triggerred) is 0-- if so, ignore that
error--so that your @ operator will work.


I need a deeper look on manual. This piece of code inside my error handler
did the trick:

if(error_reporting()==0){
return;
}

Thanks a lot.
--
-- Álvaro G. Vicario - Burgos, Spain
-- http://bits.demogracia.com - Mi sitio sobre programación web
-- Don't e-mail me your questions, post them to the group
--
Aug 9 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Sean Mullaly | last post by:
I have a custom Access menu with sub-menus and sub-sub-menus. (220 items). Right now I have created 220 Functions and attached each individual Function to the specific OnAction property. The...
0
by: Rhys666 | last post by:
OK, an issue I've come across before, but never found a cause for or resolution of, has decided to become the bane of my life again with ASP.Net Custom Error Pages. Basically, my web application...
3
by: Mr Newbie | last post by:
I'm testing error handling configurations and having some trouble. I created a WebForm called. ErrDefault.aspx and I am trying to use the Page error attribute to force the redirection to a custom...
15
by: bill salkin | last post by:
I'd like to create a custom error handler like this in VB.NET: .... try ... Throw ("Lender Name not in table") .... catch ("Lender Name not in table")
4
by: Paul Wilson | last post by:
I want to use Err.Raise() method to raise my own exceptions. Is this the right way of raising my own exceptions ? (i think this is the only way). What is the Error number i can safely use,...
6
by: Steve Amey | last post by:
Hi all I want to be able to throw a custom error up the call stack. I have looked around and it seems as though it's possible, but I can't get it to work :o( Below is some sample code. ...
1
by: serge calderara | last post by:
dear all, i am a bit confused on the way custom error are handling and occurs. First of all I have understand that customer error is used to defined more user friendly message to my end user and...
5
by: jegec | last post by:
Hi all! Brief subject: I have to develop an ASP-based application, and build also a specific error handling ASP. After that I had set the virtual directory Custom Error 500;100 to new ASP -...
2
hyperpau
by: hyperpau | last post by:
Before anything else, I am not a very technical expert when it comes to VBA coding. I learned most of what I know by the excellent Access/VBA forum from bytes.com (formerly thescripts.com). Ergo, I...
0
hyperpau
by: hyperpau | last post by:
Before anything else, I am not a very technical expert when it comes to VBA coding. I learned most of what I know by the excellent Access/VBA forum from bytes.com (formerly thescripts.com). Ergo, I...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.