To run OpenLayers in debug mode, include the following script tag before the tag that loads OpenLayers:
<script src="../lib/Firebug/firebug.js"></script>
With debugging, exception handling with a trace of sorts is available. Click this link and view the console to see the trace. This console can be opened by hitting F12 or Ctrl+Shift+L (?+Shift+L on a Mac).