Skip to content

Commit 8e9a8d1

Browse files
eliascarvjuliohm
andauthored
Add error message for unsupported values (#23)
* Add error message for unsupported values * Apply suggestions * Expand CI.yml config --------- Co-authored-by: Júlio Hoffimann <[email protected]>
1 parent 88112d2 commit 8e9a8d1

File tree

3 files changed

+19
-1
lines changed

3 files changed

+19
-1
lines changed

.github/workflows/CI.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,12 @@ jobs:
2323
fail-fast: false
2424
matrix:
2525
version:
26-
- '1'
2726
- '1.9'
27+
- '1'
2828
os:
2929
- ubuntu-latest
30+
- macos-latest
31+
- windows-latest
3032
arch:
3133
- x64
3234
steps:

src/Colorfy.jl

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,13 @@ end
163163
Function intended for developers that returns the mapped colors from the `colorfier` without the alphas.
164164
Alphas are applied in the `Colorfy.colors` function.
165165
"""
166+
function getcolors(colorfier::Colorfier)
167+
throw(ArgumentError("""
168+
Values of type `$(eltype(colorfier.values))` are not supported.
169+
Please make sure your vector of colors has a concrete type.
170+
"""))
171+
end
172+
166173
getcolors(colorfier::Colorfier{<:Values{Number}}) =
167174
get(colorscheme(colorfier), values(colorfier), colorrange(colorfier))
168175

test/runtests.jl

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,15 @@ using Test
7373
values = coloralpha.(colors, alphas)
7474
colorfier = Colorfier(values)
7575
@test Colorfy.colors(colorfier) == values
76+
77+
# error: unsupported values
78+
values = [nothing, nothing, nothing]
79+
colorfier = Colorfier(values)
80+
@test_throws ArgumentError Colorfy.colors(colorfier)
81+
values = Any[:red, :green, :blue] # vector with non-concrete eltype
82+
alphas = rand(3)
83+
colorfier = Colorfier(values; alphas)
84+
@test_throws ArgumentError Colorfy.colors(colorfier)
7685
end
7786

7887
@testset "colorfy" begin

0 commit comments

Comments
 (0)