Raise error if file doesn't exist.
This commit is contained in:
parent
5bdc3ab5e6
commit
e304597fab
|
|
@ -269,6 +269,9 @@ void parse_file(char const *file_path,
|
|||
file_stream.rdbuf()->pubsetbuf(&buffer[0], buffer_size);
|
||||
file_stream.open(file_path);
|
||||
|
||||
if (!file_stream)
|
||||
throw std::ios_base::failure("File doesn't exist!");
|
||||
|
||||
std::string line;
|
||||
while (std::getline(file_stream, line))
|
||||
parse_line(line, data, indices, indptr, labels);
|
||||
|
|
|
|||
|
|
@ -67,3 +67,7 @@ def test_load_invalid_file():
|
|||
@raises(TypeError)
|
||||
def test_not_a_filename():
|
||||
load_svmlight_file(1)
|
||||
|
||||
@raises(IOError)
|
||||
def test_invalid_filename():
|
||||
load_svmlight_file("trou pic nic douille")
|
||||
|
|
|
|||
Loading…
Reference in New Issue