Skip to content

Commit

Permalink
Merge pull request #16051 from brave/pr15969_fix_26805_1.46.x
Browse files Browse the repository at this point in the history
Fix error text extraction on enter sync code (uplift to 1.46.x)
  • Loading branch information
LaurenWags authored Nov 22, 2022
2 parents 6582fb0 + d09e435 commit d347a6b
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
6 changes: 6 additions & 0 deletions app/brave_settings_strings.grdp
Original file line number Diff line number Diff line change
Expand Up @@ -649,6 +649,12 @@
<message name="IDS_BRAVE_SYNC_CODE_INVALID" desc="Text for general sync setup error.">
This code is invalid
</message>
<message name="IDS_BRAVE_SYNC_CODE_EMPTY" desc="Text for empty sync setup code provided error.">
This code is empty
</message>
<message name="IDS_BRAVE_SYNC_INTERNAL_SETUP_ERROR" desc="Text for rarely occured sync setup error.">
Internal sync setup error
</message>
<message name="IDS_BRAVE_SYNC_CODE_FROM_DEPRECATED_VERSION" desc="Text for error when trying to use old version sync code after v1 sunset date.">
This code was generated by a deprecated version of Brave, please upgrade your other device first
</message>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ export class SettingsBraveSyncSetupElement extends SettingsBraveSyncSetupElement
try {
success = await this.syncBrowserProxy_.setSyncCode(syncCodeToSubmit)
} catch (e: unknown) {
this.syncCodeValidationError_ = (e as Error).message
this.syncCodeValidationError_ = (e as string)
success = false
}
this.isSubmittingSyncCode_ = false
Expand Down
8 changes: 6 additions & 2 deletions browser/ui/webui/settings/brave_sync_handler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,8 @@ void BraveSyncHandler::HandleSetSyncCode(const base::Value::List& args) {
const std::string time_limited_sync_code = args[1].GetString();
if (time_limited_sync_code.empty()) {
LOG(ERROR) << "No sync code parameter provided!";
RejectJavascriptCallback(args[0].Clone(), base::Value(false));
RejectJavascriptCallback(
args[0].Clone(), l10n_util::GetStringUTF8(IDS_BRAVE_SYNC_CODE_EMPTY));
return;
}

Expand All @@ -229,7 +230,10 @@ void BraveSyncHandler::HandleSetSyncCode(const base::Value::List& args) {
auto* sync_service = GetSyncService();
if (!sync_service ||
!sync_service->SetSyncCode(pure_words_with_status.value())) {
RejectJavascriptCallback(args[0].Clone(), base::Value(false));
LOG(ERROR) << "sync_service=" << sync_service;
RejectJavascriptCallback(
args[0].Clone(),
l10n_util::GetStringUTF8(IDS_BRAVE_SYNC_INTERNAL_SETUP_ERROR));
return;
}

Expand Down

0 comments on commit d347a6b

Please sign in to comment.