From ae694c9607a48c9f5d5d1395509c2ec82c802f92 Mon Sep 17 00:00:00 2001 From: Martijn Visser Date: Thu, 15 Dec 2022 14:46:00 +0100 Subject: [PATCH] replace assert with more verbose ArgumentError --- src/coord.jl | 6 +++++- test/libproj.jl | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/coord.jl b/src/coord.jl index b1880c9..4c0997a 100644 --- a/src/coord.jl +++ b/src/coord.jl @@ -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 diff --git a/test/libproj.jl b/test/libproj.jl index 3da1f80..c5da2ad 100644 --- a/test/libproj.jl +++ b/test/libproj.jl @@ -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