User Tools

Site Tools


juliaism

quick and unimportant question: What is the proper julia-ism for a custom error message incorporating the C system error, like perl's?

snippet.perl
[download only julia statements]
open(my $f, "<$filename") or warn "my error message: $!\n"

is it

try
    f= open(filename)
catch
    warn("my error message $(Libc.strerror(Libc.errno()))")
end

if so, perl's $! encourages more use than $(Libc.strerror(Libc.errno())). It's a minor nuisance, because most of the time, one uses “die” instead of “warn,” and unlike perl, julia throws an informative error by itself, albeit non-customizable. it's enough 99% of the time.

juliaism.txt · Last modified: 2018/08/21 14:17 (external edit)