Skip to content

Commit 1deb12b

Browse files
author
Michael Abbott
committed
remove println & make an error type
1 parent b156769 commit 1deb12b

File tree

1 file changed

+17
-12
lines changed

1 file changed

+17
-12
lines changed

src/graphs.jl

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -621,8 +621,7 @@ function add_operation!(
621621
elseif RHS.head === :block
622622
add_operation!(ls, LHS, strip_op_linenumber_nodes(RHS), elementbytes, position)
623623
else
624-
println(RHS)
625-
throw("Expression not recognized.")
624+
throw(LoopError("Expression not recognized.", RHS))
626625
end
627626
end
628627
add_operation!(ls::LoopSet, RHS::Expr, elementbytes::Int, position::Int) = add_operation!(ls, gensym(:LHS), RHS, elementbytes, position)
@@ -657,8 +656,7 @@ function add_operation!(
657656
elseif RHS.head === :block
658657
add_operation!(ls, LHS, strip_op_linenumber_nodes(RHS), elementbytes, position)
659658
else
660-
println(RHS)
661-
throw("Expression not recognized.")
659+
throw(LoopError("Expression not recognized.", RHS))
662660
end
663661
end
664662

@@ -722,18 +720,15 @@ function Base.push!(ls::LoopSet, ex::Expr, elementbytes::Int, position::Int)
722720
add_compute!(ls, tempunpacksym, f, vparents, elementbytes)
723721
add_store_ref!(ls, tempunpacksym, lhsi, elementbytes)
724722
else
725-
println(lhsi)
726-
throw("Unpacking the above expression in the left hand side was not understood/supported.")
723+
throw(LoopError("Unpacking the above expression in the left hand side was not understood/supported.", lhsi))
727724
end
728725
end
729726
first(vparents)
730727
else
731-
println(LHS)
732-
throw("LHS not understood; only `:ref`s and `:tuple`s are currently supported.")
728+
throw(LoopError("LHS not understood; only `:ref`s and `:tuple`s are currently supported.", LHS))
733729
end
734730
else
735-
println(LHS)
736-
throw("LHS not understood.")
731+
throw(LoopError("LHS not understood.", LHS))
737732
end
738733
elseif ex.head === :block
739734
add_block!(ls, ex, elementbytes, position)
@@ -756,8 +751,7 @@ function Base.push!(ls::LoopSet, ex::Expr, elementbytes::Int, position::Int)
756751
add_compute!(ls, LHS, :identity, [RHS], elementbytes)
757752
end
758753
else
759-
println(ex)
760-
throw("Don't know how to handle expression.")
754+
throw(LoopError("Don't know how to handle expression.", ex))
761755
end
762756
end
763757

@@ -817,3 +811,14 @@ end
817811
# order[u₁loopnum], order[u₂loopnum]
818812
# end
819813

814+
815+
struct LoopError <: Exception
816+
msg
817+
ex
818+
LoopError(msg, ex=nothing) = new(msg, ex)
819+
end
820+
821+
function Base.showerror(io::IO, err::LoopError)
822+
printstyled(io, err.msg, '\n'; color = :red)
823+
printstyled(io, err.ex)
824+
end

0 commit comments

Comments
 (0)