Standardize error handling patterns and improve ErrorHandler integration.
- Added a comprehensive error propagation standardization report detailing dominant patterns, inconsistencies, and recommended remediations (`docs/audits/error-propagation-standardization.md`). - Integrated `ErrorHandler` into key components, including `main.cc` for robust exception reporting, and added centralized logging to a user state path. - Introduced EINTR-safe syscall wrappers (`SyscallWrappers.h`, `.cc`) to improve resilience of file and metadata operations. - Enhanced `DEVELOPER_GUIDE.md` with an error handling conventions section, covering pattern guidelines and best practices. - Identified gaps in `PieceTable` and internal helpers; deferred fixes with detailed recommendations for improved memory allocation error reporting.
This commit is contained in:
76
SyscallWrappers.cc
Normal file
76
SyscallWrappers.cc
Normal file
@@ -0,0 +1,76 @@
|
||||
#include "SyscallWrappers.h"
|
||||
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/stat.h>
|
||||
#include <cerrno>
|
||||
#include <cstdlib>
|
||||
|
||||
namespace kte {
|
||||
namespace syscall {
|
||||
int
|
||||
Open(const char *path, int flags, mode_t mode)
|
||||
{
|
||||
int fd;
|
||||
do {
|
||||
fd = ::open(path, flags, mode);
|
||||
} while (fd == -1 && errno == EINTR);
|
||||
return fd;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
Close(int fd)
|
||||
{
|
||||
int ret;
|
||||
do {
|
||||
ret = ::close(fd);
|
||||
} while (ret == -1 && errno == EINTR);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
Fsync(int fd)
|
||||
{
|
||||
int ret;
|
||||
do {
|
||||
ret = ::fsync(fd);
|
||||
} while (ret == -1 && errno == EINTR);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
Fstat(int fd, struct stat *buf)
|
||||
{
|
||||
int ret;
|
||||
do {
|
||||
ret = ::fstat(fd, buf);
|
||||
} while (ret == -1 && errno == EINTR);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
Fchmod(int fd, mode_t mode)
|
||||
{
|
||||
int ret;
|
||||
do {
|
||||
ret = ::fchmod(fd, mode);
|
||||
} while (ret == -1 && errno == EINTR);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
Mkstemp(char *template_str)
|
||||
{
|
||||
int fd;
|
||||
do {
|
||||
fd = ::mkstemp(template_str);
|
||||
} while (fd == -1 && errno == EINTR);
|
||||
return fd;
|
||||
}
|
||||
} // namespace syscall
|
||||
} // namespace kte
|
||||
Reference in New Issue
Block a user