Just to clarify this. The problem seems to be with the $node that gets assigned on line 202. It appears that $node is null and then the script redirects to the 'error' sitemap location.
Initial impressions are that the node is null because it has yet to be created. It will be created when the post is approved but this doesn't help with the redirect which will occur before that action takes place. Maybe the code should check the workflow requests?
Another point is that this code doesn't seem to respect the settings within site.ini.php where the default and error pages are defined.