Page 1 of 1

Solved: Errors/ Execptions in PHP

Posted: Tue Mar 17, 2009 10:40 am
by a.heresey
I believe I have risen to the level that I need to start "handling" my errors instead of running away from them.

The basic concepts, however, still elude me. Here's an example:

Code: Select all

 if (!valid$_POST['requiredThing']){
  return 'invalid entry, go back';
}else{
  $cornerstone = cornerstonefunc($_POST);
  try{
     append_myDoc($cornerstone, 'myFile.xml');
  }catch(Exception $e){
    echo 'Caught Exception: '. $e->getCode() . ' Message: ' . $e->getMessage(). "\n Couldn't save file.";
  }
  $block1 = $cornerstone->saveXML();
  $stuff = $myXSLTrans($block1, 'myXSL.xsl');
}
$output = '<h1>STUFF</h1>' . $stuff . '<p>Hope you enjoyed that.</p>'
What should happen:

Code: Select all

[size=150]<h1>STUFF</h1>
<p>XML made HTML!</p>
<p>Hope you enjoyed that.</p>[/size]
What does happen:

Code: Select all

[size=150]<h1>STUFF</h1>
<p></p>
<p>Hope you enjoyed that.</p>
[/size]
No errors, no exceptions logged. myFile.xml has the expected output.

I thought that after the try block, lines 10 and 11 would get executed? I'm not very familiar with try...catch, so I think it's the problem.

Re: Errors/ Execptions in PHP

Posted: Tue Mar 17, 2009 11:11 pm
by a.heresey
Problem was in the xsl. :P