## exception-name.pkg
# Compiled by:
#
src/lib/std/src/standard-core.sublib# Eventually, this should move to PreBasis so that we
# don't need the PreGeneral package anymore.
### "When I like people immensely,
### I never tell their names to any one.
### It is like surrendering a part of them."
### -- Oscar Wilde
### "I never made a mistake in my life;
### At least, never one that I couldn't
### explain away afterwards."
###
### -- Rudyard Kipling
# This package gets 'include'd by:
#
#
src/lib/std/exceptions.pkgstipulate
package xih = exception_info_hook; # exception_info_hook is from
src/lib/core/init/exception-info-hook.pkg package iox = io_exceptions; # io_exceptions is from
src/lib/std/src/io/io-exceptions.pkg package wnx = winix_guts; # winix_guts is from
src/lib/std/src/posix/winix-guts.pkg # inline_t is from
src/lib/core/init/built-in.pkgherein
package exception_name
: (weak)
api {
exception_name: Exception -> String;
exception_message: Exception -> String;
}
{
exception_name = xih::exception_name : Exception -> String; # inline_t::cast (\\ (REF s, _, _) => s)
#
fun exception_message (wnx::RUNTIME_EXCEPTION (s, NULL))
=>
"RUNTIME_EXCEPTION: " + s;
exception_message (wnx::RUNTIME_EXCEPTION (s, THE errno)) # (strerror(errno),errno) (or whatever) from src/c/lib/raise-error.c
=>
cat ["RUNTIME_EXCEPTION: ", s, " [", wnx::error_name errno, "]"];
exception_message (iox::IO { cause, op, name } )
=>
{ cause_message
=
case cause
#
wnx::RUNTIME_EXCEPTION (s, _) => [", ", s];
iox::BLOCKING_IO_NOT_SUPPORTED => [", blocking I/O not supported"];
iox::RANDOM_ACCESS_IO_NOT_SUPPORTED => [", random access not supported"];
iox::TERMINATED_INPUT_STREAM => [", terminated input stream"];
iox::CLOSED_IO_STREAM => [", closed stream"];
_ => [" with exception ", exception_message cause];
esac;
cat ("Io: " ! op ! " failed on \"" ! name ! "\"" ! cause_message);
};
exception_message (DIE s) => "DIE: " + s;
exception_message BIND => "nonexhaustive naming failure"; # NOTE: we should probably include line/file info for MATCH and BIND XXX BUGGO FIXME
exception_message MATCH => "nonexhaustive match failure";
exception_message INDEX_OUT_OF_BOUNDS => "index out of bounds";
exception_message SIZE => "size";
exception_message OVERFLOW => "overflow";
exception_message DIVIDE_BY_ZERO => "divide by zero";
exception_message DOMAIN => "domain error";
exception_message e => exception_name e;
end;
my _ =
xih::exception_message_hook
:=
exception_message;
};
end;
## COPYRIGHT (c) 1995 AT&T Bell Laboratories.
## Subsequent changes by Jeff Prothero Copyright (c) 2010-2015,
## released per terms of SMLNJ-COPYRIGHT.