Please upgrade here. These earlier versions are no longer being updated and have security issues.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.

display a error message with vanilla style

naquadaqnaquadaq New
edited July 2012 in Vanilla 2.0 - 2.8

Hello,

I have written a SSO plugin and I want to display an error message with the vanilla style with the current theme. How can I do it?

Tagged:

Comments

  • what type of error?

    validation, notfound, denied, etc

    grep is your friend.

  • It is a LTI plugin so they will be messages when a external application passes on the request information to my plugin. This plugin handles authentication a validation of the information received
    One of the messages p.e, is 'LTI context not available but needed. Proceess aborted'
    In fact, I think it doesn't matter the type of message. In general I would like to display a personalized message. Now I'm using echo and exit and redirect.

  • When I interpret the text from your reply to x00, I would say the errortype would be 'validation'. Let's see if Garden has a special errortype for that. Please add a Wiki page when you've found what you're looking for, explaining how to use, etc. :-)

    There was an error rendering this rich post.

  • x00x00 MVP
    edited July 2012

    Well it matter in terms of style, status codes etc. Whether true error, just relaying information.

    if you just want a bonk/debug message then use

    throw new ErrorException('Error Message.');
    

    A useful method that I have used for permission errors is

    $Message = T('You do not have permission to bla, bla, bla');
    Gdn::Locale()->SetTranslation('PermissionErrorMessage',$Message));
    throw new Exception($Message,401);
    

    However there isn't a general error message page other than Bonk, and debug mode (which isn't ideal to show) If you include a view like so, it will display roughly equivalent.

    <div class="SplashInfo">
       <h1><?php echo T('Error Message Title'); ?></h1>
       <p><?php echo T('Error Message'); ?></p>
    </div>
    

    If you want those inline red validation messages, a bit like flash

    <div class="Messages Errors">
    <ul>
        <li><?php echo T('Error Message'); ?></li>
    </ul>
    </div>
    

    You can also use inform messages for more low key notification.

    grep is your friend.

  • Eventually, I have used the PermissionErrorMessage.
    For one case, which displayed more information, I have used a simple echo because I wanted to add more views to the plugin.

    Thank you for your help.

Sign In or Register to comment.