mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2024-12-26 01:35:34 +08:00
Merge pull request #4709 from aignatov-bio/ai-sci-7572-fix-label-template-error-handling
Fix label template error handling [SCI-7572]
This commit is contained in:
commit
fa6311382e
1 changed files with 10 additions and 10 deletions
|
@ -1,12 +1,10 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module LabelTemplates
|
||||
class ColumnNotFoundError < StandardError; end
|
||||
class LogoNotFoundError < StandardError; end
|
||||
class LogoParamsError < StandardError; end
|
||||
|
||||
class RepositoryRowService
|
||||
class UnsupportedKeyError < StandardError; end
|
||||
|
||||
class ColumnNotFoundError < StandardError; end
|
||||
|
||||
class LogoNotFoundError < StandardError; end
|
||||
|
||||
MAX_PRINTABLE_ITEM_NAME_LENGTH = 64
|
||||
|
||||
|
@ -21,7 +19,9 @@ module LabelTemplates
|
|||
keys = @label_template.content.scan(/(?<=\{\{).*?(?=\}\})/).uniq
|
||||
label = keys.reduce(@label_template.content.dup) do |rendered_content, key|
|
||||
rendered_content.gsub!(/\{\{#{key}\}\}/, fetch_value(key))
|
||||
rescue ColumnNotFoundError, LogoNotFoundError => e
|
||||
rescue LabelTemplates::ColumnNotFoundError,
|
||||
LabelTemplates::LogoNotFoundError,
|
||||
LabelTemplates::LogoParamsError => e
|
||||
errors.push(e)
|
||||
rendered_content
|
||||
end
|
||||
|
@ -49,7 +49,7 @@ module LabelTemplates
|
|||
when /^c_(.*)/
|
||||
name = Regexp.last_match(1)
|
||||
unless @repository_columns.include?(name)
|
||||
raise ColumnNotFoundError, I18n.t('label_templates.repository_row.errors.column_not_found')
|
||||
raise LabelTemplates::ColumnNotFoundError, I18n.t('label_templates.repository_row.errors.column_not_found')
|
||||
end
|
||||
|
||||
fetch_custom_column_value(name)
|
||||
|
@ -64,12 +64,12 @@ module LabelTemplates
|
|||
when /^LOGO/
|
||||
logo(key)
|
||||
else
|
||||
raise ColumnNotFoundError, I18n.t('label_templates.repository_row.errors.column_not_found')
|
||||
raise LabelTemplates::ColumnNotFoundError, I18n.t('label_templates.repository_row.errors.column_not_found')
|
||||
end
|
||||
end
|
||||
|
||||
def logo(_key)
|
||||
raise LogoNotFoundError, I18n.t('label_templates.repository_row.errors.logo_not_supported')
|
||||
raise LabelTemplates::LogoNotFoundError, I18n.t('label_templates.repository_row.errors.logo_not_supported')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue