felixse/FluentTerminal · error · ReadTextFileException
Failed to read the file.
Error message
Failed to read the file.
What it means
Thrown by TrayProcessCommunicationService.ReadTextFileAsync when the tray process returns a StringValueResponse with Success == false and a blank Error. Same IPC delegation pattern as SaveTextFileAsync: the UWP app asks the Win32 tray to read a file and, on opaque failure, reports a generic 'Failed to read the file.' message.
Source
Thrown at FluentTerminal.App.Services/Implementation/TrayProcessCommunicationService.cs:93
var response =
await GetResponseAsync<CommonResponse>(new SaveTextFileRequest {Path = path, Content = content})
.ConfigureAwait(false);
if (!response.Success)
{
throw new SaveTextFileException(string.IsNullOrEmpty(response.Error)
? "Failed to save the file."
: response.Error);
}
}
public async Task<string> ReadTextFileAsync(string path)
{
var response = await GetResponseAsync<StringValueResponse>(new ReadTextFileRequest { Path = path }).ConfigureAwait(false);
if (!response.Success)
{
throw new ReadTextFileException(string.IsNullOrWhiteSpace(response.Error) ? "Failed to read the file." : response.Error);
}
return response.Value;
}
public async Task<string> GetSshConfigDirAsync()
{
if (!string.IsNullOrEmpty(_sshConfigDir))
{
return _sshConfigDir;
}
var response =
await GetResponseAsync<GetSshConfigFolderResponse>(new GetSshConfigFolderRequest
{ IncludeContent = false }).ConfigureAwait(false);
if (response.Success)
{View on GitHub (pinned to ba83ec485e)
Solutions
- Confirm the file exists and is readable at the given path before requesting it.
- Ensure the tray-side ReadTextFile handler populates response.Error with the real exception message.
- Verify the tray process is running and has the needed privileges.
- Catch ReadTextFileException at the call site and degrade gracefully (e.g. return empty/default).
Example fix
// before
throw new ReadTextFileException(string.IsNullOrWhiteSpace(response.Error) ? "Failed to read the file." : response.Error);
// after (tray side) - propagate the underlying cause
// catch (Exception ex) { return new StringValueResponse { Success = false, Error = ex.Message }; } Defensive patterns
Strategy: try-catch
Validate before calling
if (string.IsNullOrWhiteSpace(path)) throw new ArgumentException("path required");
if (!System.IO.File.Exists(path)) throw new System.IO.FileNotFoundException(path); Try / catch
try { content = await tray.ReadTextFileAsync(path); }
catch (ReadTextFileException ex) { logger.Warn(ex, "read failed"); content = null; } Prevention
- Check File.Exists and readability before requesting via the tray.
- Make the tray handler return the underlying exception in response.Error.
- Keep a fallback/default when a read is non-critical.
- Verify the tray process is alive.
When it happens
Trigger: ReadTextFileRequest is sent for a path the tray cannot read: missing file, access-denied, path too long, or unreadable encoding. Success=false with empty Error triggers the fallback string.
Common situations: Requested file does not exist; path is outside permitted access; file is locked exclusively by another process; tray process lacks read permission; tray handler swallowed the exception without setting Error.
Related errors
AI-assisted analysis of felixse/FluentTerminal@ba83ec485e (2026-08-13).
Data as JSON: /api/errors/b87f6b7505220fff.
Report an issue: GitHub.