Commit 3da6281d authored by Mosè Giordano's avatar Mosè Giordano
Browse files

Strip whitespaces when reporting error messages from `readSBML`

Also:

* replace `@warn` with `@error`
* actually test the logging message in `readSBML`, instead of showing an extra
  message saying to ignore it.
parent 41a25d0d
...@@ -99,8 +99,8 @@ function readSBML(fn::String, sbml_conversion = document -> nothing)::SBML.Model ...@@ -99,8 +99,8 @@ function readSBML(fn::String, sbml_conversion = document -> nothing)::SBML.Model
n_errs = ccall(sbml(:SBMLDocument_getNumErrors), Cuint, (VPtr,), doc) n_errs = ccall(sbml(:SBMLDocument_getNumErrors), Cuint, (VPtr,), doc)
for i = 0:n_errs-1 for i = 0:n_errs-1
err = ccall(sbml(:SBMLDocument_getError), VPtr, (VPtr, Cuint), doc, i) err = ccall(sbml(:SBMLDocument_getError), VPtr, (VPtr, Cuint), doc, i)
msg = get_string(err, :XMLError_getMessage) msg = strip(get_string(err, :XMLError_getMessage))
@warn "SBML reported error: $msg" @error "SBML reported error: $msg"
end end
if n_errs > 0 if n_errs > 0
throw(AssertionError("Opening SBML document has reported errors")) throw(AssertionError("Opening SBML document has reported errors"))
......
...@@ -18,8 +18,7 @@ end ...@@ -18,8 +18,7 @@ end
@test typeof(mdl) == Model @test typeof(mdl) == Model
@info "The next warning is an expected side-effect of testing an error condition" @test_logs (:error, "SBML reported error: File unreadable.") @test_throws AssertionError readSBML(sbmlfile * ".does.not.really.exist")
@test_throws AssertionError readSBML(sbmlfile * ".does.not.really.exist")
@test length(mdl.compartments) == 2 @test length(mdl.compartments) == 2
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment