Plugin Development 1.2.3: throwing formatted Exceptions

Get help from other users here.

Moderators: Developer, Contributor

Post Reply
dandjo
Posts: 14
Joined: 15 Oct 2010, 12:50

Plugin Development 1.2.3: throwing formatted Exceptions

Post by dandjo »

Hi friends,

in my plugin, there's a class that throws Exceptions (with "throw new Exception('Desc');"). How do I ensure to display this Exceptions like the APPLICATTION ERROR #XXX Mantis throws itself?
Thanks!

Kind regards,
dandjo
Kirill
Posts: 640
Joined: 25 Nov 2007, 08:05
Location: Kaliningrad, RF
Contact:

Re: Plugin Development 1.2.3: throwing formatted Exceptions

Post by Kirill »

Look source about string trigger_error(
message for error can be stored in lang files of your plugins
dandjo
Posts: 14
Joined: 15 Oct 2010, 12:50

Re: Plugin Development 1.2.3: throwing formatted Exceptions

Post by dandjo »

Hm, trigger_error() just lets me define a code and a localized text, i wanted to print the exception and the stacktrace.

I also didn't get how to use $MANTIS_ERROR[XXX] = 'localized text' in plugindir/lang/strings_english.txt to display with trigger_errur(XXX, ERROR). Pleas help! :)
Kirill
Posts: 640
Joined: 25 Nov 2007, 08:05
Location: Kaliningrad, RF
Contact:

Re: Plugin Development 1.2.3: throwing formatted Exceptions

Post by Kirill »

pluginname/pluginname.php

Code: Select all

if ($error) {
            error_parameters( plugin_lang_get( 'my_error' ) );
            trigger_error( ERROR_PLUGIN_GENERIC, ERROR );
} 
pluginname/lang/strings_english.php

Code: Select all

$s_plugin_pluginname_error_my_error = 'This text of my errors';
 
dandjo
Posts: 14
Joined: 15 Oct 2010, 12:50

Re: Plugin Development 1.2.3: throwing formatted Exceptions

Post by dandjo »

Thanks, I found a smarter way

Code: Select all

if ($error) {
  plugin_error(plugin_lang_get('my_error'), ERROR);
}
Post Reply