Strengthened error handling for malformed URI's