AcademicBenchmark: fix missing error message
There are several fatal errors that can be encountered in an import. these were previously being reported as warnings, which is not accurate. Additionally, the error message was not being set properly so in the outcomes import API we were getting back a null error message. Fixes CNVS-22517 Test Plan: Most of these conditions are difficult to reproduce because they result from the Academic Benchmarks server. Therefore, there isn't really a practical test plan we can do without building an emulator (which I actually would like to do when we have a little time) Change-Id: I521fc5250a3369497944cda5e44bbbc622f46681 Reviewed-on: https://gerrit.instructure.com/60876 Reviewed-by: John Corrigan <jcorrigan@instructure.com> Product-Review: Benjamin Porter <bporter@instructure.com> QA-Review: Benjamin Porter <bporter@instructure.com> Tested-by: Jenkins
This commit is contained in:
parent
f30e329d8c
commit
89aed994f9
|
@ -55,8 +55,14 @@ module AcademicBenchmark
|
|||
def convert_file
|
||||
data = @api.parse_ab_data(@archive_file.read)
|
||||
process_json_data(data)
|
||||
rescue APIError
|
||||
add_warning(I18n.t("academic_benchmark.bad_ab_file", "The provided Academic Benchmark file has an error."), $!)
|
||||
rescue APIError => e
|
||||
add_error(
|
||||
I18n.t("The provided Academic Benchmark file has an error"),
|
||||
{
|
||||
exception: e,
|
||||
error_message: e.message
|
||||
}
|
||||
)
|
||||
end
|
||||
|
||||
def convert_authorities(authorities=[])
|
||||
|
@ -74,8 +80,17 @@ module AcademicBenchmark
|
|||
def refresh_outcomes(opts)
|
||||
res = build_full_auth_hash(opts)
|
||||
process_json_data(res)
|
||||
rescue EOFError, APIError
|
||||
add_warning(I18n.t("academic_benchmark.api_error", "Couldn't update standards for authority %{auth}.", :auth => opts[:authority] || opts[:guid]), $!)
|
||||
rescue EOFError, APIError => e
|
||||
add_error(
|
||||
I18n.t(
|
||||
"Couldn't update standards for authority %{auth}",
|
||||
:auth => opts[:authority] || opts[:guid]
|
||||
),
|
||||
{
|
||||
exception: e,
|
||||
error_message: e.message
|
||||
}
|
||||
)
|
||||
end
|
||||
|
||||
# get a shallow tree for the authority then process the leaves
|
||||
|
@ -126,8 +141,14 @@ module AcademicBenchmark
|
|||
end
|
||||
|
||||
set_progress(95)
|
||||
rescue APIError
|
||||
add_warning(I18n.t("academic_benchmark.bad_response_all", "Couldn't update the standards."), $!)
|
||||
rescue APIError => e
|
||||
add_error(
|
||||
I18n.t("Previously unhandled error encountered while refreshing outcomes"),
|
||||
{
|
||||
exception: e,
|
||||
error_message: e.message
|
||||
}
|
||||
)
|
||||
end
|
||||
|
||||
def process_json_data(data)
|
||||
|
@ -135,7 +156,10 @@ module AcademicBenchmark
|
|||
outcomes = Standard.new(data).build_outcomes
|
||||
@course[:learning_outcomes] << outcomes
|
||||
else
|
||||
add_warning(I18n.t("academic_benchmark.no_authority", "Couldn't find an authority to update"))
|
||||
err_msg = I18n.t("Couldn't find an authority to update")
|
||||
add_error(
|
||||
err_msg, { exception: nil, error_message: err_msg }
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -224,8 +224,6 @@ describe AcademicBenchmark::Converter do
|
|||
run_jobs
|
||||
@cm.reload
|
||||
|
||||
er = ErrorReport.last
|
||||
expect(@cm.old_warnings_format).to eq [["Couldn't update standards for authority CC.", "ErrorReport:#{er.id}"]]
|
||||
expect(@cm.migration_settings[:last_error]).to be_nil
|
||||
expect(@cm.workflow_state).to eq 'imported'
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue