Skip to content

Commit 5322388

Browse files
committed
Preserve exception types in throw diagnostics
1 parent ca2cc21 commit 5322388

3 files changed

Lines changed: 2 additions & 6 deletions

File tree

src/compiler/transform/throws.jl

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -116,10 +116,6 @@ function exception_message(sci::StructuredIRCode, def_index, block::Block,
116116

117117
ex = thrown_exception(sci, def_index, block, exception)
118118
if ex !== nothing
119-
if hasfield(typeof(ex), :msg) && isdefined(ex, :msg)
120-
msg = getfield(ex, :msg)
121-
msg isa AbstractString && return String(msg)
122-
end
123119
return sprint(showerror, ex)
124120
end
125121

test/codegen/integration.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -695,7 +695,7 @@ end
695695
@testset "Julia throws" begin
696696
@testset "conditional throw lowers to a runtime assertion" begin
697697
@test @filecheck begin
698-
@check "assert {{.*}}x must be positive"
698+
@check "assert {{.*}}ArgumentError: x must be positive"
699699
code_tiled(Tuple{Int32}) do x
700700
x > Int32(0) || throw(ArgumentError("x must be positive"))
701701
return

test/codegen/operations.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -781,7 +781,7 @@ spec4d = ct.ArraySpec{4}(16, true)
781781
end
782782
@test err isa cuTile.CodegenErrors
783783
@test only(err.errors).msg ==
784-
"Vector-vector multiplication is not supported. Use dot(a, b) for inner products, or reshape explicitly."
784+
"ArgumentError: Vector-vector multiplication is not supported. Use dot(a, b) for inner products, or reshape explicitly."
785785
end
786786

787787
@testset "4D batched matmul (2 batch dims)" begin

0 commit comments

Comments
 (0)