API - Error Management in Joomla 1.5

For Joomla! 1.5 Coding related discussions, please use: http://groups.google.com/group/joomla-dev-general
Locked
User avatar
louis.landry
Joomla! Ace
Joomla! Ace
Posts: 1380
Joined: Wed Aug 17, 2005 11:03 pm
Location: San Jose, California
Contact:

API - Error Management in Joomla 1.5

Post by louis.landry » Thu Dec 15, 2005 8:44 pm

Hello all,

I thought I would quickly go over one of the changes in the upcoming 1.5 release.  Though it was not part of the original roadmap for 1.5, the team determined that it would be beneficial to have a common error manager in Joomla.  This would provide a common interface for both the core and 3rd party developers to handle errors.  After some research was done, the decision was made to wrap the existing patError class that is packaged with patTemplate.  This system provides a whole host of functionality and remains quite lightweight considering its power.  The necessary functionality has been wrapped by a new static class called: JError.

For an overview of how patError works please see: http://www.php-tools.net/site.php?&file ... erview.xml

For online documentation of patError please see: http://www.php-tools.net/site.php?&file ... /intro.xml

Obviously we will be creating our own documentation and a how-to guide for third party developers as well.  The JError class can be seen in the file: JROOT/libraries/joomla/classes/error.php

A couple of the advantages of using this class will be that all error conditions will have a universal look/feel for the user, and if used properly the user would have exactly the information needed for a developer to fix a bug.

Also, an error system template has been created for displaying errors.  This goes a long way to keeping Joomla looking good, even in the worst of times :)


Obviously more information to come...

Louis
Last edited by Jinx on Sat Apr 01, 2006 11:35 pm, edited 1 time in total.
Joomla Platform Maintainer
A hacker does for love what others would not do for money.

User avatar
interfaSys
Joomla! Apprentice
Joomla! Apprentice
Posts: 18
Joined: Fri Aug 19, 2005 12:15 am
Location: Lausanne, Switzerland
Contact:

Re: Error Management in Joomla 1.1

Post by interfaSys » Thu Dec 15, 2005 9:01 pm

Sounds great!
Olivier
interfaSys sàrl

User avatar
DumbAss
Joomla! Apprentice
Joomla! Apprentice
Posts: 21
Joined: Sat Oct 08, 2005 12:17 pm

Re: API - Error Management in Joomla 1.1

Post by DumbAss » Tue Feb 14, 2006 9:11 pm

Sounds greet indead. For developers it's very welcome and I hope it speeds up development. Error handling eats up most of my time  :P

User avatar
torkil
Joomla! Guru
Joomla! Guru
Posts: 726
Joined: Wed Aug 24, 2005 9:34 am
Location: Rørvik, Norway
Contact:

Re: API - Error Management in Joomla 1.1

Post by torkil » Thu Mar 09, 2006 7:34 pm

Sounds great. Some examples on how to put it to good use in a joomla application would be nice... Or some pointers to core Joomla code that uses it perhaps?

User avatar
Jinx
Joomla! Champion
Joomla! Champion
Posts: 6508
Joined: Fri Aug 12, 2005 12:47 am
Contact:

Re: API - Error Management in Joomla 1.1

Post by Jinx » Thu Mar 09, 2006 8:28 pm

We will try to provide more documentation in the coming weeks. The error handlers are used in the different classes in the framework. A good start is the JFTP class.
Johan Janssens - Joomla Co-Founder, Lead Developer of Joomla 1.5

http://www.joomlatools.com - Joomla extensions that just work

User avatar
torkil
Joomla! Guru
Joomla! Guru
Posts: 726
Joined: Wed Aug 24, 2005 9:34 am
Location: Rørvik, Norway
Contact:

Re: API - Error Management in Joomla 1.1

Post by torkil » Fri Mar 10, 2006 1:08 pm

The JFTP class ideed uses the JError class extensively. I still have to probe a bit further on these error codes.... :)

To sum up: How does one put the error codes to good use when developing third party components?

For instance, from the mkdir function in the JFTP class there is this line of code:

Code: Select all

JError::raiseError('35', 'JFTP::mkdir: Bad response.', 'Server response:'.$this->_response.' [Expected: 257] Path sent:'.$path );
Why is the error code 35 used in here? What good does it do? What does it refer to? Will this result in a 500 error since it is not a 403 or 404?

Louis wrote this paragraph in the dev blog:
The default case for errors is a 500 error, because if access isn’t forbidden or the page is not available… obviously there is something wrong within the Joomla! code execution so its an internal server error… make sense? Good.
Does he mean "...if access isn't forbidden and the page is available..." (403 or 404) then the error is an internal server error (500)?

User avatar
PhilTaylor-Prazgod
Joomla! Ace
Joomla! Ace
Posts: 1402
Joined: Sat Aug 20, 2005 12:32 pm
Location: Jersey, Channel Islands
Contact:

Re: API - Error Management in Joomla 1.5

Post by PhilTaylor-Prazgod » Mon Oct 09, 2006 4:48 pm

The links the documentation and overview are not correct after the recent change on their site:

Try this instead:
http://trac.php-tools.net/patError/wiki
http://trac.php-tools.net/patError/wiki/Docs
Phil Taylor
- https://mySites.guru - Manage Multiple Joomla/WordPress Sites In One Dashboard for Security, Audits, Backups and more....
- https://www.phil-taylor.com/

User avatar
Chris Davenport
Joomla! Ace
Joomla! Ace
Posts: 1370
Joined: Thu Aug 18, 2005 8:57 am
Location: Shrewsbury, Shropshire, United Kingdom

Re: API - Error Management in Joomla 1.5

Post by Chris Davenport » Wed Oct 11, 2006 11:04 am

PhilTaylor-Prazgod wrote: The links the documentation and overview are not correct after the recent change on their site:
I've fixed the only link I know about (http://dev.joomla.org/component/option, ... es:jerror/).

Please let me know if you are aware of any other bad links.

Thanks Phil.

Regards,
Chris.
Chris Davenport

Davenport Technology Services http://www.davenporttechnology.com/
Lion Coppice http://www.lioncoppice.org/

User avatar
Chris Davenport
Joomla! Ace
Joomla! Ace
Posts: 1370
Joined: Thu Aug 18, 2005 8:57 am
Location: Shrewsbury, Shropshire, United Kingdom

Re: API - Error Management in Joomla 1.5

Post by Chris Davenport » Sat Jan 13, 2007 5:16 pm

Hi,

Just thought I'd add a quick note to say that the JError class is no longer dependent on patError.

If someone has the time to re-read and revise (or even extend!) the Joomla! Error Handling guidelines page: http://dev.joomla.org/component/option, ... es:jerror/ I would be very grateful.

Please submit your amendments here: http://forum.joomla.org/index.php/board,287.0.html.

Regards,
Chris.
Chris Davenport

Davenport Technology Services http://www.davenporttechnology.com/
Lion Coppice http://www.lioncoppice.org/

Joombla
Joomla! Intern
Joomla! Intern
Posts: 71
Joined: Mon Sep 12, 2005 7:54 am

Re: API - Error Management in Joomla 1.5

Post by Joombla » Fri May 25, 2007 2:46 am

I tried executing a mysql query after calling JError::raiseError(); to log errors, but it looks like it doesn't work. Does raising an error block mysql queries? The specific method I was calling is insertObject.

Regards,
Todd

StarShaper
Joomla! Explorer
Joomla! Explorer
Posts: 347
Joined: Wed Sep 27, 2006 11:55 pm

Re: API - Error Management in Joomla 1.5

Post by StarShaper » Tue Aug 21, 2007 4:09 pm

I think Exceptions would be a great addition. The next version should go fully PHP5. :)

User avatar
torkil
Joomla! Guru
Joomla! Guru
Posts: 726
Joined: Wed Aug 24, 2005 9:34 am
Location: Rørvik, Norway
Contact:

Re: API - Error Management in Joomla 1.5

Post by torkil » Wed Mar 26, 2008 11:13 am

Nothing wrong with using regular PHP Exceptions. JError::isError($obj) is fully capable of determining if $obj is a JException, JError og regular PHP Exception object.

Note:
JException also uses the same function names as the regular PHP Exception class, so it doesn't even take any time getting used to :)
Last edited by torkil on Wed Mar 26, 2008 11:28 am, edited 1 time in total.

User avatar
torkil
Joomla! Guru
Joomla! Guru
Posts: 726
Joined: Wed Aug 24, 2005 9:34 am
Location: Rørvik, Norway
Contact:

Re: API - Error Management in Joomla 1.5

Post by torkil » Wed Mar 26, 2008 11:19 am

I have another question though, related to errors:

How is the JObject error functions intended to work into this? Most classes inherit from JObject and can thus use the error-related functions from JObject, but what is the thought behind for instance setError, getError and getErrors? Are we supposed to use this as a storing mechanism for storing multiple errors?

User avatar
Jinx
Joomla! Champion
Joomla! Champion
Posts: 6508
Joined: Fri Aug 12, 2005 12:47 am
Contact:

Re: API - Error Management in Joomla 1.5

Post by Jinx » Wed Mar 26, 2008 12:56 pm

Yes, the idea is that you can store multiple errors in the object. These errors can be errors, notices, warnings or messages and can be retrieved to be acted upon.
Johan Janssens - Joomla Co-Founder, Lead Developer of Joomla 1.5

http://www.joomlatools.com - Joomla extensions that just work

bt-t
Joomla! Apprentice
Joomla! Apprentice
Posts: 38
Joined: Fri Jul 24, 2009 8:35 am
Contact:

Re: API - Error Management in Joomla 1.5

Post by bt-t » Fri Jul 31, 2009 9:13 am

Jinx wrote:Yes, the idea is that you can store multiple errors in the object. These errors can be errors, notices, warnings or messages and can be retrieved to be acted upon.
This sounds great... I hope er can use it soon .

triman101
Joomla! Apprentice
Joomla! Apprentice
Posts: 9
Joined: Wed Aug 25, 2010 8:59 am

Re: API - Error Management in Joomla 1.1

Post by triman101 » Wed Aug 25, 2010 11:36 am

Jinx wrote:We will try to provide more documentation in the coming weeks. The error handlers are used in the different classes in the framework. A good start is the JFTP class.
I just wanted to update error management thread with couple of resources for developers, since I see nobody done it:

http://api.joomla.org/Joomla-Framework/ ... Error.html
http://docs.joomla.org/JError

Regards


Locked

Return to “Joomla! 1.5 Coding”