How can I get the intended URL in a 404?

$_SERVER['REQUEST_URI'] is your only option. wordpress failed parsing the url so not much you can get from the API

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)