We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 15083
    • 697 Posts
    I know I know....don’t ignore warnings etc smiley

    I have found an annoying recurring problem when writing snippets for MODx.
    If I try to use @ error suppression the MODx parser error still fires and takes over the page. This is a problem as I may want to more gracefully show the user a message like "Feed unavailable" having tried to retrive an rss feed, failed and then fallen back on a more discreet error?

    Is there a way to avoid this happening? The code i’m using:

    $doc = new DOMDocument();
    $url = ’rssurl’;

    if(!@$doc->load($url)){
    throw new MyCustomException(’message’);
    }

    However if the above fails the MODx parser error message takes over my page....
      • 10487 MODX Staff
      • 1,535 Posts
      What version of MODx are you using? There have been changes to the MODx error handling in recent releases to allow for error suppression (can’t remember off the top of my head whether they got included in 0.9.6.2 or 0.9.6.3, I’d have to cross-check the SVN changelog)
        Garry Nutting
        Senior Developer
        MODX, LLC

        Email: [email protected]
        Twitter: @garryn
        Web: modx.com
        • 15083
        • 697 Posts
        this version is 0.9.6.1p2
        I can upgrade it if I can get around the above without relying on include files etc...
          • 10487 MODX Staff
          • 1,535 Posts
          Yeah, I’d recommend upgrading - not only should it solve the error suppression problems but there’s been a whole host of other bugfixes between your version and 0.9.6.3.
            Garry Nutting
            Senior Developer
            MODX, LLC

            Email: [email protected]
            Twitter: @garryn
            Web: modx.com
            • 7231
            • 4,205 Posts
            Quote from: garryn at Feb 18, 2009, 09:38 AM

            There have been changes to the MODx error handling in recent releases to allow for error suppression
            Does this mean that we could now use the @ for error suppression? That is interesting.
              [font=Verdana]Shane Sponagle | [wiki] Snippet Call Anatomy | MODx Developer Blog | [nettuts] Working With a Content Management Framework: MODx

              Something is happening here, but you don't know what it is.
              Do you, Mr. Jones? - [bob dylan]
              • 9021
              • 40 Posts
              guys,

              I have the problem mentioned above, with exactly the same php functions. I am running 0962 but due to some encoding problems I cannot upgrade to 0963 yet. Due to modx’ error handling, I cannot suppress the warnings the load function throws. I have no influence on the html so I cannot make sure it is correct.

              What would be an alternative way to do this?