Skip to content

Commit

Permalink
replace assert with more verbose ArgumentError
Browse files Browse the repository at this point in the history
  • Loading branch information
visr committed Dec 15, 2022
1 parent 2c3cd96 commit ae694c9
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
6 changes: 5 additions & 1 deletion src/coord.jl
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,11 @@ function Transformation(
ctx::Ptr{PJ_CONTEXT}=C_NULL
)
pj = proj_create(pipeline, ctx)
@assert !Bool(proj_is_crs(pj)) "Not a transformation (but a CRS):\n$pipeline"
if Bool(proj_is_crs(pj))
throw(ArgumentError("""Cannot create a Transformation from a single CRS.
Pass either one pipeline or a source and target CRS.
CRS given: $(repr(pipeline))"""))
end
pj = always_xy ? normalize_axis_order!(pj; ctx) : pj
return Transformation(pj, direction)
end
Expand Down
2 changes: 1 addition & 1 deletion test/libproj.jl
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ end
@test inv(PJ_IDENT) == PJ_IDENT
@test inv(PJ_INV) == PJ_FWD

@test_throws AssertionError Proj.Transformation("EPSG:28992")
@test_throws ArgumentError Proj.Transformation("EPSG:28992")
trans = Proj.Transformation("+proj=pipeline +ellps=GRS80 +step +proj=merc +step +proj=axisswap +order=2,1")

end
Expand Down

0 comments on commit ae694c9

Please sign in to comment.