I would like to know what are the possible and appropriate methods for error handling within postnuke (0.8)?
I did not find anything about that in the documentation Wiki.
Watch
GitHub Core
Show your support for Zikula! Sign up at Github account and watch the Core project!
GitHub Modules
- internetking created topic »password problem« 25. May
- mesteele101 responded to »ERR (3): E_USER_ERROR: Smarty error: [in pagesvar:pagesitem2en line XXX]…« 25. May
- mazdev responded to »Pages 2.5.0 and updating - Page not found« 25. May
- ehdwma created topic »Hide "Register new account" and change template to 3 col« 25. May
- mesteele101 responded to »Zikula 1.3.3 - Selecting a category in Pages not working« 25. May
- mdee created topic »How to implement returnpage ?« 25. May
- nestormateo responded to »Fillters in Clip« 24. May
Zikula Blog
- Anatomy of Open Source Projects on Mar 07
- Continuous Review on Mar 01
- Not Invented Here on Feb 24
- How to Contribute Your Code at Github on Jan 13
- 10 Steps to Coding-Nirvana: Tips for Successful Module Writing on Nov 12
- Submitting Bug Report Tickets That Get Results on Aug 17
- Cozi Tricks #1: Syntax Highlighting on Aug 07
Login
Error Handling in PN
-
- Rank: Team Member
- Registered: Jan 05, 2003
- Last visit: May 28, 2010
- Posts: 775
If you mean error and status message logging, this has just been changed after the release of MS2. The underlying data structure has been changed to be array-based. In a parallel move, the API has been extended to provide functions to handle the error and status message through the LogUtil class. The entire PN codebase has been updated to reflect this change.
The net result of this is that we can now capture and display multiple erros which also have the ability to display some more informative supporting info which will make tracking and solving such errors much easier.
Does that answer your question?
Greetings
R -
- Rank: Expert
- Registered: Nov 23, 2003
- Last visit: Dec 13, 2009
- Posts: 1487
rgasch
The underlying data structure has been changed to be array-based... The net result of this is that we can now capture and display multiple erros
"YEAH!", cried the people... and there was much rejoicing!
--
Under Construction! -
**unknown user**
- Rank: Softmore
- Registered: Mar 16, 2002
- Last visit: Oct 21, 2009
- Posts: 111
Sounds great, and how does the implementation work? What I see in the example modules at the moment looks like this:
Code
if ($dict->ExecuteSQLArray($sqlarray) != 2) {
pnSessionSetVar('errormsg', _EXAMPLECREATETABLEFAILED);
return false;
}
or
Code
if (!pnSecAuthAction(0, 'Example::', '::', ACCESS_OVERVIEW)) {
return DataUtil::formatForDisplayHTML(_MODULENOAUTH);
}
How do I modify these to reflect new way to code them?
edited by: come, Oct 15, 2006 - 09:57 PM -
- Rank: Team Member
- Registered: Jan 05, 2003
- Last visit: May 28, 2010
- Posts: 775
The 1st code sample you pasted above now becomes:
Code
if ($dict->ExecuteSQLArray($sqlarray) != 2) {
return LogUtil::registerError (_EXAMPLECREATETABLEFAILED);
}
The 2nd piece of code you pasted hasn't been changed yet in the PN codebase, but it should probably also be converted to use LogUtil::registerError().
Greetings
R
-
**unknown user**
- Rank: Softmore
- Registered: Mar 16, 2002
- Last visit: Oct 21, 2009
- Posts: 111
I just noticed that the LogUtil::registerError is already implemented in the .8 nightly build, but when I exchange the LogUtil lib in my .8MS2 installation I get the following error when loading my test module without necessary permissions:
Quote
Failed to load module HelloWorld (at function: main
When I have all permissions everything works fine.
The pnuser.php looks like this
Code
function HelloWorld_user_main()
{
if(!(SecurityUtil::checkPermission('HelloWorld::', '::', ACCESS_OVERVIEW))) {
return LogUtil::registerError(_MODULENOAUTH);
}
...
}
What other files do I need to exchange to get it to work? -
- Rank: Team Member
- Registered: Jan 05, 2003
- Last visit: May 28, 2010
- Posts: 775
I think you need the following files:
includes/pnAPI.php
includes/pnAPI.php
includes/pnobjlib/LogUtil.class.php
includes/pnobjlib/AjaxUtil.class.php
system/Groups/pnajax.php
pnRender/plugins/function.pngetstatusmsg.php
However, please note:
1) The internal variable names have changed _PNErrorMsg and _PNStatusMsg
2) Due to #1 the old pnSessionSetVar() calls (ie: every such call which is in the MS2 codebase) still work (in the sense that they will execute without error) but they have no effect anymore. Calling pnSessionSetVar() on _PNErrorMsg or _PNStatusMsg will trigger an error as this old-style use would overwrite the arrays with a string.
So as you can see, these changes in turn necessitate a lot of follup-up changes. As such, it might be easiest to just grab the current CVS code ...
Greetings
R -
- Rank: Team Member
- Registered: Jan 05, 2003
- Last visit: May 28, 2010
- Posts: 775
Quote
Failed to load module HelloWorld (at function: main
It would seem that this is an error generated somewhere in the pnModLoad() function. I'm not sure if this has anythig to do with the changes in LogUtil ...
Do other modules work?
Greetings
R -
**unknown user**
- Rank: Softmore
- Registered: Mar 16, 2002
- Last visit: Oct 21, 2009
- Posts: 111
I took the ValueAddon module News for a test and only changed the DataUtil::formatForDisplayHTML() in News_user_main() to LogUtil::registerError(). When triggering the error with insufficient permissions I get the "failed to load module" error. With the right permissions or with the DataUtil function everything works as expected. -
- Rank: Team Member
- Registered: Jan 05, 2003
- Last visit: May 28, 2010
- Posts: 775
Interesting. Can you please log a bug for this in the NOC and tell me as accurately as possible how to reproduce this?
The code fundamentally works, but it seems that I've overlooked something.
Greetings/Thanks
R -
- Rank: Team Member
- Registered: Mar 18, 2002
- Last visit: Oct 21, 2009
- Posts: 6606
Take a look at the next daily (or look at SVN) as i've done some work on bringing together the LogUtil class that Robert authored and the Errors module - the purpose of which is to display useful errors.
LogUtil has also been extended a bit to allow for setting of some error types which result in relevant HTTP headers being sent.
All system modules have been updated to utilise the new error handling.
-Mark
--
Visit My homepage and Zikula themes.
- Moderated by:
- Support
Users on-line
- 0 users
This list is based on users active over the last 60 minutes.
