5#include "../Common/ResultErrorFormatter.h"
6#include "FileSystemWatcherError.h"
19 case FileSystemWatcherErrorDetail::None:
return true;
20 case FileSystemWatcherErrorDetail::AssignWatchPath: formatter.append(
"assign watch path");
break;
21 case FileSystemWatcherErrorDetail::BuildSubfolderPath: formatter.append(
"build subfolder path");
break;
22 case FileSystemWatcherErrorDetail::BuildNotificationPath: formatter.append(
"build notification path");
break;
23 case FileSystemWatcherErrorDetail::BuildFullPath: formatter.append(
"build full path");
break;
24 case FileSystemWatcherErrorDetail::WatchPathCapacity: formatter.append(
"watch path capacity");
break;
25 case FileSystemWatcherErrorDetail::WorkerAlreadyStarted: formatter.append(
"worker already started");
break;
26 case FileSystemWatcherErrorDetail::PosixPthreadCreate: formatter.append(
"POSIX create thread");
break;
27 case FileSystemWatcherErrorDetail::PosixPthreadJoin: formatter.append(
"POSIX join thread");
break;
28 case FileSystemWatcherErrorDetail::WindowsCreateThread: formatter.append(
"Windows create thread");
break;
29 case FileSystemWatcherErrorDetail::WindowsWaitForSingleObject: formatter.append(
"Windows wait for thread");
break;
30 case FileSystemWatcherErrorDetail::WindowsCreateWatchEvent: formatter.append(
"Windows create watch event");
break;
31 case FileSystemWatcherErrorDetail::WindowsSignalWatchEvent: formatter.append(
"Windows signal watch event");
break;
32 case FileSystemWatcherErrorDetail::WindowsWaitForWatchEvents:
33 formatter.append(
"Windows wait for watch events");
35 case FileSystemWatcherErrorDetail::WindowsCancelDirectoryChanges:
36 formatter.append(
"Windows cancel directory changes");
38 case FileSystemWatcherErrorDetail::PosixCreateShutdownPipe: formatter.append(
"POSIX create shutdown pipe");
break;
39 case FileSystemWatcherErrorDetail::InotifyInitialize: formatter.append(
"inotify initialize");
break;
40 case FileSystemWatcherErrorDetail::PosixWriteShutdownPipe: formatter.append(
"POSIX write shutdown pipe");
break;
41 case FileSystemWatcherErrorDetail::InotifyDescriptor: formatter.append(
"inotify descriptor");
break;
42 case FileSystemWatcherErrorDetail::InotifyRemoveWatch: formatter.append(
"inotify remove watch");
break;
43 case FileSystemWatcherErrorDetail::InotifyAddRootWatch: formatter.append(
"inotify add root watch");
break;
44 case FileSystemWatcherErrorDetail::InotifyAddSubdirectoryWatch:
45 formatter.append(
"inotify add subdirectory watch");
47 case FileSystemWatcherErrorDetail::InotifyOpenRootDirectory: formatter.append(
"inotify open root directory");
break;
48 case FileSystemWatcherErrorDetail::InotifyOpenDirectoryStream:
49 formatter.append(
"inotify open directory stream");
51 case FileSystemWatcherErrorDetail::InotifyReadDirectoryEntries:
52 formatter.append(
"inotify read directory entries");
54 case FileSystemWatcherErrorDetail::InotifyInspectDirectoryEntry:
55 formatter.append(
"inotify inspect directory entry");
57 case FileSystemWatcherErrorDetail::InotifyOpenSubdirectory: formatter.append(
"inotify open subdirectory");
break;
58 case FileSystemWatcherErrorDetail::InotifyReadEvents: formatter.append(
"inotify read events");
break;
59 case FileSystemWatcherErrorDetail::InotifyVerifyDirectoryIdentity:
60 formatter.append(
"inotify verify directory identity");
62 case FileSystemWatcherErrorDetail::InotifyWatchInvalidated: formatter.append(
"inotify watch invalidated");
break;
63 case FileSystemWatcherErrorDetail::InotifyWaitForEvents: formatter.append(
"inotify wait for events");
break;
64 case FileSystemWatcherErrorDetail::InotifyWatchHandleCapacity:
65 formatter.append(
"inotify watch handle capacity");
67 case FileSystemWatcherErrorDetail::InotifyPendingDirectoryCapacity:
68 formatter.append(
"inotify pending directory capacity");
70 case FileSystemWatcherErrorDetail::InotifyRelativePathStorage:
71 formatter.append(
"inotify relative path storage");
73 case FileSystemWatcherErrorDetail::AppleRunLoop: formatter.append(
"Apple run loop");
break;
74 case FileSystemWatcherErrorDetail::AppleCreateRunLoopSource:
75 formatter.append(
"Apple create run loop source");
77 case FileSystemWatcherErrorDetail::AppleAllocateWatchPaths: formatter.append(
"Apple allocate watch paths");
break;
78 case FileSystemWatcherErrorDetail::AppleCreateWatchPathString:
79 formatter.append(
"Apple create watch path string");
81 case FileSystemWatcherErrorDetail::AppleCreateWatchPathsArray:
82 formatter.append(
"Apple create watch paths array");
84 case FileSystemWatcherErrorDetail::AppleCreateEventStream: formatter.append(
"Apple create event stream");
break;
85 case FileSystemWatcherErrorDetail::AppleStartEventStream: formatter.append(
"Apple start event stream");
break;
86 case FileSystemWatcherErrorDetail::WindowsOpenDirectory: formatter.append(
"Windows open directory");
break;
87 case FileSystemWatcherErrorDetail::WindowsSubmitDirectoryChanges:
88 formatter.append(
"Windows submit directory changes");
90 case FileSystemWatcherErrorDetail::WindowsCompleteDirectoryChanges:
91 formatter.append(
"Windows complete directory changes");
93 case FileSystemWatcherErrorDetail::AppleOpenRootDirectory: formatter.append(
"Apple open root directory");
break;
94 case FileSystemWatcherErrorDetail::AppleResolveWatchRoot: formatter.append(
"Apple resolve watch root");
break;
95 case FileSystemWatcherErrorDetail::AppleWatchInvalidated: formatter.append(
"Apple watch invalidated");
break;
96 case FileSystemWatcherErrorDetail::WindowsQueryRootDirectory:
97 formatter.append(
"Windows query root directory");
99 default:
return false;
106 uint32_t nativeError, Span<char> output)
108 ResultErrorFormatter formatter(output);
111 case FileSystemWatcherError::NotInitialized: formatter.append(
"Watcher is not initialized");
break;
112 case FileSystemWatcherError::AlreadyWatching: formatter.append(
"Folder watcher is already watching");
break;
113 case FileSystemWatcherError::NotWatching: formatter.append(
"Folder watcher is not watching");
break;
114 case FileSystemWatcherError::UnsupportedPathEncoding: formatter.append(
"Path encoding is not supported");
break;
115 case FileSystemWatcherError::PathPreparationFailed: formatter.append(
"Failed to prepare path");
break;
116 case FileSystemWatcherError::WatchLimitExceeded: formatter.append(
"Watch capacity exceeded");
break;
117 case FileSystemWatcherError::BufferTooSmall: formatter.append(
"Buffer capacity is insufficient");
break;
118 case FileSystemWatcherError::InitializationFailed: formatter.append(
"Failed to initialize watcher");
break;
119 case FileSystemWatcherError::WatchSetupFailed: formatter.append(
"Failed to configure watching");
break;
120 case FileSystemWatcherError::StopWatchingFailed: formatter.append(
"Failed to stop watching");
break;
121 case FileSystemWatcherError::CloseFailed: formatter.append(
"Failed to close watcher");
break;
122 case FileSystemWatcherError::MonitoringFailed: formatter.append(
"Filesystem monitoring stopped");
break;
123 default:
return ResultErrorFormatter::failure(ResultErrorFormatStatus::UnknownError, output);
126 if (detail != FileSystemWatcherErrorDetail::None)
128 formatter.append(
" (detail: ");
129 if (not appendFileSystemWatcherErrorDetail(formatter, detail))
130 return ResultErrorFormatter::failure(ResultErrorFormatStatus::UnknownError, output);
131 if (nativeError != 0)
133 formatter.append(
", native error: ");
134 formatter.append(
static_cast<uint64_t
>(nativeError));
136 formatter.append(
")");
138 else if (nativeError != 0)
140 formatter.append(
" (native error: ");
141 formatter.append(
static_cast<uint64_t
>(nativeError));
142 formatter.append(
")");
144 return formatter.finish();
150 return detail::formatFileSystemWatcherErrorWithDetails(error, FileSystemWatcherErrorDetail::None, 0, output);
153inline ResultErrorFormat formatFileSystemWatcherError(Result result, Span<char> output)
156 return ResultErrorFormatter::failure(ResultErrorFormatStatus::NotAnError, output);
157 if (result.category() != FileSystemWatcherResultCategory)
158 return ResultErrorFormatter::failure(ResultErrorFormatStatus::ForeignCategory, output);
162inline ResultErrorFormat formatFileSystemWatcherError(ResultFileSystemWatcher result, Span<char> output)
165 return ResultErrorFormatter::failure(ResultErrorFormatStatus::NotAnError, output);
166 if (result.result.category() != FileSystemWatcherResultCategory)
167 return ResultErrorFormatter::failure(ResultErrorFormatStatus::ForeignCategory, output);
168 return detail::formatFileSystemWatcherErrorWithDetails(
169 static_cast<FileSystemWatcherError>(result.result.errorValue()), result.detail, result.nativeError, output);
FileSystemWatcherError
Stable portable failures returned by the FileSystemWatcher library.
Definition FileSystemWatcherError.h:14
FileSystemWatcherErrorDetail
Stable backend stages retained as context for a FileSystemWatcher failure.
Definition FileSystemWatcherError.h:31