Skip to content

Commit

Permalink
updated File Error Handling
Browse files Browse the repository at this point in the history
  • Loading branch information
daddel80 committed Feb 3, 2024
1 parent 0b706fe commit 325af63
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
5 changes: 3 additions & 2 deletions src/MultiReplacePanel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4358,12 +4358,12 @@ bool MultiReplace::saveListToCsvSilent(const std::wstring& filePath, const std::
}

outFile.close();
return true;
return !outFile.fail();;
}

void MultiReplace::saveListToCsv(const std::wstring& filePath, const std::vector<ReplaceItemData>& list) {
if (!saveListToCsvSilent(filePath, list)) {
showStatusMessage(getLangStr(L"status_unable_to_open_file"), RGB(255, 0, 0));
showStatusMessage(getLangStr(L"status_unable_to_save_file"), RGB(255, 0, 0));
return;
}

Expand Down Expand Up @@ -4539,6 +4539,7 @@ std::wstring MultiReplace::unescapeCsvValue(const std::wstring& value) {
void MultiReplace::exportToBashScript(const std::wstring& fileName) {
std::ofstream file(fileName);
if (!file.is_open()) {
showStatusMessage(getLangStr(L"status_unable_to_save_file"), RGB(255, 0, 0));
return;
}

Expand Down
2 changes: 1 addition & 1 deletion src/language_mapping.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ std::unordered_map<std::wstring, std::wstring> languageMap = {
{ L"status_invalid_column_number", L"Invalid column number" },
{ L"status_extended_delimiter_empty", L"Extended delimiter is empty" },
{ L"status_invalid_quote_character", L"Invalid quote character. Use \" or ' or leave it empty." },
{ L"status_unable_to_open_file", L"Error: Unable to open file for writing." },
{ L"status_unable_to_save_file", L"Error: Unable to open or write to file." },
{ L"status_no_valid_items_in_csv", L"No valid items found in the CSV file." },
{ L"status_list_exported_to_bash", L"List exported to BASH script." },

Expand Down

0 comments on commit 325af63

Please sign in to comment.