Skip to content
Fetching contributors…
Cannot retrieve contributors at this time
54 lines (47 sloc) 1.71 KB
/* Common error routines */
namespace Rosella.Error
{
// Throw an error.
function error(string msg, var args [slurpy])
{
var caller_ctx = get_context().caller_ctx;
var caller_sub = caller_ctx.current_sub;
var caller_namespace = caller_ctx.current_namespace;
string real_msg = sprintf(msg, args);
string err = sprintf("Rosella Error in %s.%s: %s", [caller_namespace, caller_sub, real_msg]);
die(err);
}
// Error that we are using an abstract parent method or class when we
// are expected to be using a subclass
function must_subclass(string caller)
{
throw_error("(%s) : You must use a subclass instead", caller);
}
// Error that we are attempting to use a feature which is not
// implemented yet.
function not_implemented(string func)
{
throw_error("(%s) : Not implemented", func);
}
// Error when we are attempting an invalid operation. This is used to throw
// errors from inside Rosella only. Use "error" for client programs instead
// if possible.
function invalid(string caller, string msg, var args [slurpy])
{
msg = sprintf(msg, args);
throw_error("Invalid Operation in %s: %s", caller, msg);
}
// Error when we are using an invalid type in an operation
function invalid_type(string caller, var wanted_type, var type)
{
throw_error("Invalid Type in %s: Expected %s, have %s",
caller, Rosella.get_type_name(wanted_type), Rosella.get_type_name(type)
);
}
// Throw a rosella error
function throw_error(string msg, var args [slurpy])
{
string real_msg = sprintf(msg, args);
die("Rosella " + real_msg);
}
}
Something went wrong with that request. Please try again.