Class: Fastlane::Helper::TranslationErrorHandler

Inherits:
Object
  • Object
show all
Defined in:
lib/fastlane/plugin/translate/helper/translation_error_handler.rb

Class Method Summary collapse

Class Method Details

.handle_batch_result(action, retry_count, max_retries) ⇒ Object



57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# File 'lib/fastlane/plugin/translate/helper/translation_error_handler.rb', line 57

def self.handle_batch_result(action, retry_count, max_retries)
  case action
  when :retry
    return :retry if retry_count < max_retries

    UI.error("❌ Max retries (#{max_retries}) exceeded")
    :skip
  when :skip
    :skip
  when :quit
    :quit
  else
    :continue
  end
end

.handle_rate_limit_error(_batch, batch_index, total_batches) ⇒ Object



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/fastlane/plugin/translate/helper/translation_error_handler.rb', line 18

def self.handle_rate_limit_error(_batch, batch_index, total_batches)
  options = ['Wait 60s and retry', 'Skip this batch', 'Abort translation', '❌ Quit']
  choice = UI.select("⚠️ Rate limit exceeded for batch #{batch_index + 1}/#{total_batches}",
                     options)

  case choice
  when 'Wait 60s and retry'
    UI.message('⏳ Waiting 60 seconds...')
    sleep(60)
    :retry
  when 'Skip this batch'
    UI.important("⏭️ Skipping batch #{batch_index + 1}")
    :skip
  when 'Abort translation'
    UI.user_error!('❌ Translation aborted by user')
  when '❌ Quit'
    :quit
  end
end

.handle_translation_error(error, _batch, batch_index, total_batches) ⇒ Object



38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/fastlane/plugin/translate/helper/translation_error_handler.rb', line 38

def self.handle_translation_error(error, _batch, batch_index, total_batches)
  UI.error("❌ Translation error for batch #{batch_index + 1}/#{total_batches}: #{error.message}")
  options = ['Skip this batch', 'Retry batch', 'Abort translation', '❌ Quit']
  choice = UI.select('Choose action:', options)

  case choice
  when 'Skip this batch'
    UI.important("⏭️ Skipping batch #{batch_index + 1}")
    :skip
  when 'Retry batch'
    UI.message("🔄 Retrying batch #{batch_index + 1}")
    :retry
  when 'Abort translation'
    UI.user_error!('❌ Translation aborted by user')
  when '❌ Quit'
    :quit
  end
end