Fix error callback with custom transport (#5981)
If custom transport does not return any object
then calling error callback would result in `Uncaught TypeError: right-hand side of 'in' should be an object, got undefined`.
This patch adds check if $request evaluates to something.