473,320 Members | 1,691 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,320 software developers and data experts.

check if an error has occured

dlite922
1,584 Expert 1GB
Hey guys,

I can't find a good snippet to check whether an php error has occurred (maybe warning and notices too).

I'm doing this for codeIgniter. I'm trying to prevent my template/view from rendering if an error has occured because my css file messes up the codeigniter's error message format. It just looks tacky.

error_get_last() just gets the last error which with code igniter is some timezone issue. Also, self explanatory, it gets the last error, how do I know other errors didn't occur before this one?

as a temporary solution before I render the view, i'm doing a ob_end_flush() and then check if headers_sent().

is there a better way? I don't want to create my own error handler.


Thanks,



Dan

EDIT: Actually my solution above turned out to be wrong too. ob_end_flush() sends headers so, my template never renders.
Feb 7 '10 #1
7 2638
tried try - catch statements ?
Feb 7 '10 #2
Dormilich
8,658 Expert Mod 8TB
you can catch every error below E_ERROR with set_error_handler().
Feb 7 '10 #3
dlite922
1,584 Expert 1GB
Maybe I didn't clarify enough.

Is there a PHP function or custom method that allows you to know (or check if) an error has occurred?

I can't wrap the entire framework in try catch :). I think you misunderstood me @Shabinesh.

@Dorm. That's defining my own error handler class. Yes I could do this and when an error happens, I could set a flag in a global var, file, or table, but as I mentioned in OP, I didn't want to do this. I was looking for any alternatives.

Don't think there are any. PHP 6 should have a error_get_all() function. :P

Thanks


Dan
Feb 8 '10 #4
Dormilich
8,658 Expert Mod 8TB
I can't wrap the entire framework in try catch :).
set_exception_handler(), basicly the same.

Don't think there are any. PHP 6 should have a error_get_all() function. :P
the point is, E_ERROR and above terminate your script, no matter what you do.

That's defining my own error handler class. Yes I could do this and when an error happens, I could set a flag in a global var, file, or table, but as I mentioned in OP, I didn't want to do this. I was looking for any alternatives.
IMO, poor design. a global error class allows you to dump the collected errors (e.g. by mail). I have error handling classes and they really are a live saver.
Feb 9 '10 #5
dlite922
1,584 Expert 1GB
E_ERROR and above terminate your script, no matter what you do.
They don't. CodeIgniter framework somehow captures it, displays a HTML formatted version of the error.

IMO, poor design. a global error class allows you to dump the collected errors (e.g. by mail)
CodeIgniter already has one. it logs the errors and I assume it can also email it too, that would I'd have to go and modify their error handler or put in my own customized handler.

This looks like the only solution. Is to have codeigniter halt after displaying the html formatted error.



Dan
Feb 12 '10 #6
Dormilich
8,658 Expert Mod 8TB
They don't. CodeIgniter framework somehow captures it, displays a HTML formatted version of the error.
customizing the error message is not the problem. in most cases, the problem lies in terminating the script.
Feb 12 '10 #7
dlite922
1,584 Expert 1GB
Well they capture the error, do some other stuff (I can't remember what/why), then display the error.

The problem, if I remember right, is to display the error, they use the same view functions as you would in a normal case, so it does not terminate.

I could easily fix this too, but what I also wanted to stay away from is customizing CI to a point where it's not upgradeable and will be my own custom framework. Which is right back to where I was before I was using CI.

Cheers buddy,




Dan
Feb 12 '10 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: josh dismukes | last post by:
/// here is the code i'm getting a parse error on the last line of the code which /// is </html> any help will be much appreciated. <?php session_start ();
3
by: J. Muenchbourg | last post by:
I'm getting an Exception occured error on line 4 (For i =1...) <% Function ProperCase(strIn) strOut = "" boolUp = True For i = 1 To Len(strIn) c = Mid(strIn, i, 1) if c = " " or c = "'" or c...
1
by: Mike | last post by:
Hi, I have a question about the Visual Studio .Net IDE, I am wondering if anybody has seen the same problem. The first problem is when I click on Help/Check for Update menu button, I get an...
1
by: Remo | last post by:
Hi I want to install the VS .Net 2003 Prof on my XP prof First i tryed the installation, but error occured during required comps. Reading docu, they say install required comps by hand, doing so,...
1
by: pardhi a via SQLMonster.com | last post by:
Hi when i right click table and click design table then error occured (an unexpected error occured during this operation) If any one knows please let let me know your help would be appreciated ....
2
by: sean | last post by:
Hi there, I am trying to call a C# web service from an aspx page, I have the asmx file, a user control file ascx and the aspx file. I have verified that the web service is returning correct...
6
by: Richard Loupatty | last post by:
Hi all, Does someone know what this mean: The check of the signature failed for assembly 'Infragistics.WebUI.UltraWebGrid.v2' I also did a post to Infragistics but maybe this is a general...
4
by: Slasher186 | last post by:
Hi all, First of all, I'm sorry if I posted at the wrong section here, but I can't seem to find the VB 6.0 newsgroup ? I'm developing my apps with VB 6.0 sp5 installed on win xp. I have create...
4
by: David Lozzi | last post by:
Howdy, I found a nice little book called ASP.NET 2.0 Cookbook by Michael A Kittel and Geoffrey LeBlond. Anyway, they have some instructions on how to setup application level error handling. Most...
3
by: kanimozhiz | last post by:
I have created the Data access Logic component and when I execute the DALC an error occured like this "Cannot implicitly convert type 'x' to 'y'. An explicit conversion exists (are you missing a...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.