Fix incorrect exception type when double slash paths are used.

Fixes #3838