Berry `file.write()` raises an exception on failure (ex: disk full) (#21849)

This commit is contained in:
s-hadinger 2024-07-26 12:44:25 +02:00 committed by GitHub
parent 4cf741e6eb
commit 035daa663b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 5 additions and 1 deletions

View File

@ -18,6 +18,7 @@ All notable changes to this project will be documented in this file.
### Fixed ### Fixed
- Berry `light.get` for separate RGB/CT (#21818) - Berry `light.get` for separate RGB/CT (#21818)
- Berry `bytes` setters and getters with negative offsets (#21835) - Berry `bytes` setters and getters with negative offsets (#21835)
- Berry `file.write()` raises an exception on failure (ex: disk full)
### Removed ### Removed
- Berry internal: remove class from closure to simplify code (#21839) - Berry internal: remove class from closure to simplify code (#21839)

View File

@ -26,7 +26,10 @@ static int i_write(bvm *vm)
} else { } else {
data = be_tobytes(vm, 2, &size); data = be_tobytes(vm, 2, &size);
} }
be_fwrite(fh, data, size); size_t bw = be_fwrite(fh, data, size);
if (bw != size) {
be_raise(vm, "io_error", "write failed");
}
} }
be_return_nil(vm); be_return_nil(vm);
} }