Jump to content

error while throwing exception


JimBurnett

Recommended Posts

Posted

While implementing this code for getting secondary groups, 

my localhost instance through this whoops exception: 

image.thumb.png.089bc111353ff66c4964f7e86e74abfb.png

Is there something else that I need to do to get this line to work

//\IPS\Output::i()->error( 'node_error', 'YOUR_ERROR_CODE', 404, '' );

?

It seems it's looking for a template, but a directory doesn't exist?

Posted

Doesn't seem to be related to the code that you linked to in the other topic. 

This isn't related to directories. This is you (or someone) song something like $obj->directory, but $obj is not an object. 

Without seeing the actual hook code, I can't be more specific. 

Posted

On the surface, it appears that the problem is you are attempting to throw an error (the code you commented out) before the dispatcher has actually finished initializing. Because of this, $this->application within the dispatcher has not been set yet, and so later when \IPS\Dispatcher\Front::i()->application->directory is called (during output) it throws an error.

You should essentially never need to throw an actual error message when writing an SSO plugin (which I assume is what you are doing based on the stacktrace you provided). If it is imperative to show an error, you should probably set a session variable or similar, and add another hook later in the code execution that picks this up and shows the error after the dispatcher is initialized.

Posted

Ok thanks.   I don't think I need to throw the error really, I was just trying to use the code as-is that adriano provided.

 

Thank you all for the responses & bfarber for the explanation -- you are right, I'm writing an SSO plugin.   I appreciate the help.

Archived

This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...