Terminate after warning is thrown - global setting

Julia doesn’t “throw” warnings. However, warning messages are typically written to the stderr stream, so you can turn such warnings to errors simply by redirecting stderr to a read-only stream:

julia> redirect_stderr(open(touch(tempname()), "r"))
IOStream(<file ...>)

julia> @warn "foo"
ERROR: ArgumentError: write failed, IOStream is not writeable

(With a bit more work, I guess you could change stderr to a pipeline of some sort that captures the warning message and re-prints it.)

1 Like