use shutdown error values to throw exceptions in close stream

This commit is contained in:
Adrián Arroyo Calle
2021-09-30 00:10:03 +02:00
parent 4d0998ef72
commit 47d811c250
2 changed files with 17 additions and 36 deletions

View File

@@ -2704,7 +2704,12 @@ impl MachineState {
}
if !stream.is_stdin() && !stream.is_stdout() && !stream.is_stderr() {
if stream.is_closed() {
let close_result = stream.close();
if let Some(ref alias) = stream.options().alias {
indices.stream_aliases.remove(alias);
}
if let Err(_) = close_result {
let stub = MachineError::functor_stub(
clause_name!("close"),
1,
@@ -2721,12 +2726,6 @@ impl MachineState {
),
stub,
));
} else {
stream.close();
if let Some(ref alias) = stream.options().alias {
indices.stream_aliases.remove(alias);
}
}
}
}