Page 1 of 1

Plugin Development 1.2.3: throwing formatted Exceptions

Posted: 19 Oct 2010, 08:20
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

Re: Plugin Development 1.2.3: throwing formatted Exceptions

Posted: 19 Oct 2010, 08:28
by Kirill
Look source about string trigger_error(
message for error can be stored in lang files of your plugins

Re: Plugin Development 1.2.3: throwing formatted Exceptions

Posted: 19 Oct 2010, 09:03
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! :)

Re: Plugin Development 1.2.3: throwing formatted Exceptions

Posted: 19 Oct 2010, 10:12
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';
 

Re: Plugin Development 1.2.3: throwing formatted Exceptions

Posted: 19 Oct 2010, 11:29
by dandjo
Thanks, I found a smarter way

Code: Select all

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