fix(sentry/rna): add error context when RNA schema failed
This commit is contained in:
parent
820cb4bd27
commit
e63e4fc975
1 changed files with 16 additions and 8 deletions
|
@ -15,10 +15,17 @@ class APIEntreprise::RNAAdapter < APIEntreprise::Adapter
|
||||||
|
|
||||||
def process_params
|
def process_params
|
||||||
params = data_source[:association]
|
params = data_source[:association]
|
||||||
|
|
||||||
|
Sentry.with_scope do |scope|
|
||||||
|
scope.set_tags(siret: @siret)
|
||||||
|
scope.set_extras(source: params)
|
||||||
|
|
||||||
params = params&.slice(*attr_to_fetch) if @depreciated
|
params = params&.slice(*attr_to_fetch) if @depreciated
|
||||||
params[:rna] = data_source.dig(:association, :id)
|
params[:rna] = data_source.dig(:association, :id)
|
||||||
|
|
||||||
if params[:rna].present? && valid_params?(params)
|
if params[:rna].present? && valid_params?(params)
|
||||||
params = params.transform_keys { |k| :"association_#{k}" }.deep_stringify_keys
|
params = params.transform_keys { |k| :"association_#{k}" }.deep_stringify_keys
|
||||||
|
|
||||||
raise InvalidSchemaError.new(schemer.validate(params).to_a) unless schemer.valid?(params)
|
raise InvalidSchemaError.new(schemer.validate(params).to_a) unless schemer.valid?(params)
|
||||||
|
|
||||||
params
|
params
|
||||||
|
@ -26,6 +33,7 @@ class APIEntreprise::RNAAdapter < APIEntreprise::Adapter
|
||||||
{}
|
{}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def schemer
|
def schemer
|
||||||
@schemer ||= JSONSchemer.schema(Rails.root.join('app/schemas/association.json'))
|
@schemer ||= JSONSchemer.schema(Rails.root.join('app/schemas/association.json'))
|
||||||
|
|
Loading…
Reference in a new issue