- Moderated by:
- Support
-
- rank:
-
Helper
- registered:
- December 1969
- Status:
- offline
- last visit:
- 01.07.08
- Posts:
- 137
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.
--
greetings,
O. Encke
ASUS Notebook Forum -
- rank:
-
Professional
- registered:
- January 2003
- Status:
- offline
- last visit:
- 26.11.08
- Posts:
- 568
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:
-
Professional
- registered:
- November 2003
- Status:
- online
- Posts:
- 1678
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! -
- rank:
-
Helper
- registered:
- December 1969
- Status:
- offline
- last visit:
- 01.07.08
- Posts:
- 137
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
--
greetings,
O. Encke
ASUS Notebook Forum -
- rank:
-
Professional
- registered:
- January 2003
- Status:
- offline
- last visit:
- 26.11.08
- Posts:
- 568
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
-
- rank:
-
Helper
- registered:
- December 1969
- Status:
- offline
- last visit:
- 01.07.08
- Posts:
- 137
Thanks. The LogUtil::registerError function doesn't seem to be integrated in .8MS2 yet. When will it be available?
--
greetings,
O. Encke
ASUS Notebook Forum -
- rank:
-
Helper
- registered:
- December 1969
- Status:
- offline
- last visit:
- 01.07.08
- Posts:
- 137
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?
--
greetings,
O. Encke
ASUS Notebook Forum -
- rank:
-
Professional
- registered:
- January 2003
- Status:
- offline
- last visit:
- 26.11.08
- Posts:
- 568
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:
-
Helper
- registered:
- December 1969
- Status:
- offline
- last visit:
- 01.07.08
- Posts:
- 137
I now got the exact same error with the complete 2006-10-17 cvs snapshot (fresh installation).
edited by: come, Oct 18, 2006 - 04:13 AM
--
greetings,
O. Encke
ASUS Notebook Forum -
- rank:
-
Professional
- registered:
- January 2003
- Status:
- offline
- last visit:
- 26.11.08
- Posts:
- 568
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 -
- rank:
-
Helper
- registered:
- December 1969
- Status:
- offline
- last visit:
- 01.07.08
- Posts:
- 137
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.
--
greetings,
O. Encke
ASUS Notebook Forum -
- rank:
-
Professional
- registered:
- January 2003
- Status:
- offline
- last visit:
- 26.11.08
- Posts:
- 568
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:
-
Moderator
- registered:
- March 2002
- Status:
- offline
- last visit:
- 26.08.08
- Posts:
- 7720
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
