Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

iox-#2023 Improve error messages #2127

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ enum class FileStatError
{
IoFailure,
FileTooLarge,
BadFileDescriptor,
UnknownError,
};

Expand All @@ -44,6 +45,7 @@ enum class FileSetOwnerError
PermissionDenied,
ReadOnlyFilesystem,
InvalidUidOrGid,
BadFileDescriptor,
UnknownError,
};

Expand All @@ -52,6 +54,7 @@ enum class FileSetPermissionError
{
PermissionDenied,
ReadOnlyFilesystem,
BadFileDescriptor,
UnknownError,
};

Expand Down
16 changes: 13 additions & 3 deletions iceoryx_hoofs/posix/design/source/file_management_interface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ expected<iox_stat, FileStatError> get_file_status(const int fildes) noexcept
{
switch (result.error().errnum)
{
case EBADF:
IOX_LOG(ERROR, "The provided file descriptor is invalid.");
return err(FileStatError::BadFileDescriptor);
case EIO:
IOX_LOG(ERROR, "Unable to acquire file status since an io failure occurred while reading.");
return err(FileStatError::IoFailure);
Expand All @@ -41,7 +44,7 @@ expected<iox_stat, FileStatError> get_file_status(const int fildes) noexcept
"corresponding structure.");
return err(FileStatError::FileTooLarge);
default:
IOX_LOG(ERROR, "Unable to acquire file status due to an unknown failure");
IOX_LOG(ERROR, "Unable to acquire file status due to an unknown failure. errno: " << result.error().errnum);
return err(FileStatError::UnknownError);
}
}
Expand All @@ -57,6 +60,9 @@ expected<void, FileSetOwnerError> set_owner(const int fildes, const uid_t uid, c
{
switch (result.error().errnum)
{
case EBADF:
IOX_LOG(ERROR, "The provided file descriptor is invalid.");
return err(FileSetOwnerError::BadFileDescriptor);
case EPERM:
IOX_LOG(ERROR, "Unable to set owner due to insufficient permissions.");
return err(FileSetOwnerError::PermissionDenied);
Expand All @@ -75,7 +81,7 @@ expected<void, FileSetOwnerError> set_owner(const int fildes, const uid_t uid, c
IOX_LOG(ERROR, "Unable to set owner since an interrupt was received.");
return err(FileSetOwnerError::Interrupt);
default:
IOX_LOG(ERROR, "Unable to set owner since an unknown error occurred.");
IOX_LOG(ERROR, "Unable to set owner since an unknown error occurred. errno: " << result.error().errnum);
return err(FileSetOwnerError::UnknownError);
}
}
Expand All @@ -91,14 +97,18 @@ expected<void, FileSetPermissionError> set_permissions(const int fildes, const a
{
switch (result.error().errnum)
{
case EBADF:
IOX_LOG(ERROR, "The provided file descriptor is invalid.");
return err(FileSetPermissionError::BadFileDescriptor);
case EPERM:
IOX_LOG(ERROR, "Unable to adjust permissions due to insufficient permissions.");
return err(FileSetPermissionError::PermissionDenied);
case EROFS:
IOX_LOG(ERROR, "Unable to adjust permissions since it is a read-only filesystem.");
return err(FileSetPermissionError::ReadOnlyFilesystem);
default:
IOX_LOG(ERROR, "Unable to adjust permissions since an unknown error occurred.");
IOX_LOG(ERROR,
"Unable to adjust permissions since an unknown error occurred. errno: " << result.error().errnum);
return err(FileSetPermissionError::UnknownError);
}
}
Expand Down