Skip to content

Commit

Permalink
filehandle: Return some more useful error strings
Browse files Browse the repository at this point in the history
Signed-off-by: Derek Buitenhuis <[email protected]>
  • Loading branch information
dwbuiten committed Apr 29, 2024
1 parent a6e19b7 commit d7c86dd
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/core/filehandle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,22 +60,22 @@ void FileHandle::Seek(int64_t offset, int origin) {
int64_t ret = avio_seek(avio, offset, origin);
if (ret < 0)
throw FFMS_Exception(error_source, error_cause,
"Failed to seek in '" + filename + "'");
"Failed to seek in '" + filename + "': " + AVErrorToString(ret));
}

int64_t FileHandle::Tell() {
int64_t ret = avio_tell(avio);
if (ret < 0)
throw FFMS_Exception(error_source, error_cause,
"Failed to read position in '" + filename + "'");
"Failed to read position in '" + filename + "': " + AVErrorToString(ret));
return ret;
}

size_t FileHandle::Read(char *buffer, size_t size) {
int count = avio_read(avio, (unsigned char *)buffer, size);
if (count < 0)
throw FFMS_Exception(error_source, FFMS_ERROR_FILE_READ,
"Failed to read from '" + filename + "'");
"Failed to read from '" + filename + "': " + AVErrorToString(count));
return (size_t)count;
}

Expand All @@ -84,15 +84,15 @@ size_t FileHandle::Write(const char *buffer, size_t size) {
avio_flush(avio);
if (avio->error < 0)
throw FFMS_Exception(error_source, FFMS_ERROR_FILE_WRITE,
"Failed to write to '" + filename + "'");
"Failed to write to '" + filename + "': " + AVErrorToString(avio->error));
return size;
}

int64_t FileHandle::Size() {
int64_t size = avio_size(avio);
if (size < 0)
throw FFMS_Exception(error_source, FFMS_ERROR_FILE_READ,
"Failed to get file size for '" + filename + "'");
"Failed to get file size for '" + filename + "': " + AVErrorToString(size));
return size;
}

Expand Down

0 comments on commit d7c86dd

Please sign in to comment.