Get the invalid URL which throw a 404
My bad, i had one of those blind drupal moment :)

Yes it seem that drupal can't find the url because of the 404 which become the current node, but with some PHP we can still get it.

  $pageURL = 'http';
 if ($_SERVER["HTTPS"] == "on") {$pageURL .= "s";}
 $pageURL .= "://";
 if ($_SERVER["SERVER_PORT"] != "80") {
  $pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];
 } else {
  $pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
 }
  print $pageURL; 


[that is not my code, so thank you Google.]