4#include "../Common/ResultErrorFormatter.h"
5#include "FileSystemIteratorError.h"
16 uint32_t nativeError, uint16_t depth,
19 ResultErrorFormatter formatter(output);
22 case FileSystemIteratorError::NotInitialized: formatter.append(
"File system iterator is not initialized");
break;
23 case FileSystemIteratorError::InvalidRecursionState:
24 formatter.append(
"Directory recursion is not valid in the current state");
26 case FileSystemIteratorError::UnsupportedPathEncoding: formatter.append(
"Path encoding is not supported");
break;
27 case FileSystemIteratorError::PathTooLong: formatter.append(
"Directory path is too long");
break;
28 case FileSystemIteratorError::RecursionLimitExceeded:
29 formatter.append(
"Directory recursion storage is exhausted");
31 case FileSystemIteratorError::PathResolutionFailed: formatter.append(
"Failed to resolve directory path");
break;
32 case FileSystemIteratorError::OpenDirectoryFailed: formatter.append(
"Failed to open directory");
break;
33 case FileSystemIteratorError::DirectoryEnumerationFailed: formatter.append(
"Failed to enumerate directory");
break;
34 default:
return ResultErrorFormatter::failure(ResultErrorFormatStatus::UnknownError, output);
37 if (detail != FileSystemIteratorErrorDetail::None)
39 formatter.append(
" (detail: ");
42 case FileSystemIteratorErrorDetail::WindowsResolveLogicalPath:
43 formatter.append(
"Windows resolve logical path");
45 case FileSystemIteratorErrorDetail::BuildPath: formatter.append(
"build traversal path");
break;
46 case FileSystemIteratorErrorDetail::PosixOpen: formatter.append(
"POSIX open directory");
break;
47 case FileSystemIteratorErrorDetail::PosixFdOpenDir:
48 formatter.append(
"POSIX initialize directory enumeration");
50 case FileSystemIteratorErrorDetail::WindowsFindFirstFile:
51 formatter.append(
"Windows begin directory enumeration");
53 case FileSystemIteratorErrorDetail::PushRecursionState: formatter.append(
"push recursion state");
break;
54 case FileSystemIteratorErrorDetail::PosixReadDir: formatter.append(
"POSIX read directory entry");
break;
55 case FileSystemIteratorErrorDetail::WindowsFindNextFile:
56 formatter.append(
"Windows read directory entry");
58 default:
return ResultErrorFormatter::failure(ResultErrorFormatStatus::UnknownError, output);
62 formatter.append(
", native error: ");
63 formatter.append(
static_cast<uint64_t
>(nativeError));
65 formatter.append(
", depth: ");
66 formatter.append(
static_cast<uint64_t
>(depth));
67 formatter.append(
")");
69 else if (nativeError != 0)
71 formatter.append(
" (native error: ");
72 formatter.append(
static_cast<uint64_t
>(nativeError));
73 formatter.append(
", depth: ");
74 formatter.append(
static_cast<uint64_t
>(depth));
75 formatter.append(
")");
77 else if (error == FileSystemIteratorError::RecursionLimitExceeded)
79 formatter.append(
" (depth: ");
80 formatter.append(
static_cast<uint64_t
>(depth));
81 formatter.append(
")");
83 return formatter.finish();
90 return detail::formatFileSystemIteratorErrorWithContext(error, FileSystemIteratorErrorDetail::None, 0, 0, output);
97 return ResultErrorFormatter::failure(ResultErrorFormatStatus::NotAnError, output);
98 if (result.category() != FileSystemIteratorResultCategory)
99 return ResultErrorFormatter::failure(ResultErrorFormatStatus::ForeignCategory, output);
107 return ResultErrorFormatter::failure(ResultErrorFormatStatus::NotAnError, output);
108 if (result.result.category() != FileSystemIteratorResultCategory)
109 return ResultErrorFormatter::failure(ResultErrorFormatStatus::ForeignCategory, output);
110 return detail::formatFileSystemIteratorErrorWithContext(
112 result.depth, output);
FileSystemIteratorError
Stable error codes returned by the FileSystemIterator library.
Definition FileSystemIteratorError.h:13
FileSystemIteratorErrorDetail
Stable detail identifying the backend stage of a FileSystemIterator failure.
Definition FileSystemIteratorError.h:26
ResultErrorFormat formatFileSystemIteratorError(FileSystemIteratorError error, Span< char > output)
Formats a canonical English FileSystemIterator diagnostic into caller-owned storage.
Definition FileSystemIteratorErrorFormatter.h:88
FileSystemIterator result retaining optional native, backend-stage, and directory-depth details.
Definition FileSystemIteratorError.h:48