Skip to content

Commit

Permalink
feat: reduce error severity for files being updated. (#623)
Browse files Browse the repository at this point in the history
  • Loading branch information
katerina20 authored and yzerk committed Aug 28, 2023
1 parent 08e2870 commit 0a922dd
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,7 @@ public void updateSource(Long sourceId, UpdateFileRequest request) throws Respon
Map<BiPredicate<String, String>, ResponseException> errorHandlers = new LinkedHashMap<BiPredicate<String, String>, ResponseException>() {{
put((code, message) -> message.contains("File from storage with id #" + request.getStorageId() + " was not found"), new RepeatException());
put((code, message) -> StringUtils.contains(message, "Invalid SRX specified"), new ResponseException("Invalid SRX file specified"));
put((code, message) -> code.equals("409"), new FileInUpdateException());
}};
executeRequestWithPossibleRetry(
errorHandlers,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package com.crowdin.cli.client;

public class FileInUpdateException extends ResponseException {
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.crowdin.cli.client.CrowdinProjectFull;
import com.crowdin.cli.client.EmptyFileException;
import com.crowdin.cli.client.ExistsResponseException;
import com.crowdin.cli.client.FileInUpdateException;
import com.crowdin.cli.client.ProjectClient;
import com.crowdin.cli.commands.NewAction;
import com.crowdin.cli.commands.Outputter;
Expand Down Expand Up @@ -223,6 +224,13 @@ public void act(Outputter out, PropertiesWithFiles pb, ProjectClient client) {
} else {
out.println(fileFullPath);
}
} catch (FileInUpdateException e) {
if (!plainView) {
out.println(
SKIPPED.withIcon(String.format(RESOURCE_BUNDLE.getString("message.file_being_updated"), fileFullPath)));
} else {
out.println(RESOURCE_BUNDLE.getString("message.file_being_updated"));
}
} catch (Exception e) {
errorsPresented.set(true);
throw new RuntimeException(String.format(RESOURCE_BUNDLE.getString("error.uploading_file"), fileFullPath), e);
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/messages/messages.properties
Original file line number Diff line number Diff line change
Expand Up @@ -526,6 +526,7 @@ message.new_version_text.2=Changelog: @|cyan https://github.com/crowdin/crowdin-
message.new_version_text.3=Please update for the best experience!
message.uploading_file=File @|bold '%s'|@
message.uploading_file_skipped=File @|bold '%s'|@ was skipped since it is empty
message.file_being_updated=File @|bold '%s'|@ is currently being updated
message.downloaded_file=File @|bold '%s'|@
message.translation_file=Translation file @|bold '%s'|@
message.build_language_archive=Building ZIP archive with the latest translations for @|bold '%s'|@
Expand Down

0 comments on commit 0a922dd

Please sign in to comment.