File tree 3 files changed +34
-9
lines changed
3 files changed +34
-9
lines changed Original file line number Diff line number Diff line change @@ -183,8 +183,12 @@ class MemFilesystem::File : public MemFilesystem::FSNode {
183
183
assert (buffer);
184
184
185
185
if (offset + nbytes > size_)
186
- return LOG_STATUS (
187
- Status_MemFSError (" Cannot read from file; Read exceeds file size" ));
186
+ return LOG_STATUS (Status_MemFSError (fmt::format (
187
+ " Cannot read from file; Read exceeds file size: offset {} nbytes {} "
188
+ " size_ {}" ,
189
+ offset,
190
+ nbytes,
191
+ size_)));
188
192
189
193
memcpy (buffer, (char *)data_ + offset, nbytes);
190
194
return Status::Ok ();
Original file line number Diff line number Diff line change @@ -273,8 +273,15 @@ void Posix::read(
273
273
auto path = uri.to_path ();
274
274
uint64_t file_size;
275
275
this ->file_size (URI (path), &file_size);
276
- if (offset + nbytes > file_size)
277
- throw IOError (" Cannot read from file; Read exceeds file size" );
276
+ if (offset + nbytes > file_size) {
277
+ throw IOError (fmt::format (
278
+ " Cannot read from file; Read exceeds file size: offset {}, nbytes {}, "
279
+ " file_size {}, URI {}" ,
280
+ offset,
281
+ nbytes,
282
+ file_size,
283
+ uri.to_path ()));
284
+ }
278
285
279
286
// Open file
280
287
int fd = open (path.c_str (), O_RDONLY);
Original file line number Diff line number Diff line change 58
58
#include " uri.h"
59
59
#include " win.h"
60
60
61
+ #include < fmt/format.h>
62
+
61
63
using namespace tiledb ::common;
62
64
using tiledb::common::filesystem::directory_entry;
63
65
@@ -462,11 +464,23 @@ Status Win::read(
462
464
0 ) {
463
465
auto gle = GetLastError ();
464
466
CloseHandle (file_h);
465
- return LOG_STATUS (Status_IOError (
466
- " Cannot read from file '" + path + " '; File read error " +
467
- (gle != 0 ? get_last_error_msg (gle, " ReadFile" ) :
468
- " num_bytes_read " + std::to_string (num_bytes_read) +
469
- " != nbyes " + std::to_string (nbytes))));
467
+
468
+ std::string err_msg;
469
+ if (gle != 0 ) {
470
+ err_msg = get_last_error_msg (gle, " ReadFile" );
471
+ } else {
472
+ err_msg = std::string (" num_bytes_read " ) +
473
+ std::to_string (num_bytes_read) + " != nbytes " +
474
+ std::to_string (nbytes);
475
+ }
476
+
477
+ return LOG_STATUS (Status_IOError (fmt::format (
478
+ " Cannot read from file '{}'; File read error '{}' offset {} nbytes "
479
+ " {}" ,
480
+ path,
481
+ err_msg,
482
+ offset,
483
+ nbytes)));
470
484
}
471
485
byte_buffer += num_bytes_read;
472
486
offset += num_bytes_read;
You can’t perform that action at this time.
0 commit comments