mirror of
https://github.com/dlang/phobos.git
synced 2025-05-10 05:41:56 +03:00

-- add std.getopt -- add std.variant -- switch strings over to be invariant rather than const -- hopefully the last big linux makefile overhaul -- fix for bug 1579: write[ln] fails for obj.toString() -- fix negative precision handling in std.format -- add some file and directory iterator helpers -- among other little changes here and there...
49 lines
1.1 KiB
D
49 lines
1.1 KiB
D
// Written in the D programming language
|
|
|
|
module std.switcherr;
|
|
|
|
import std.stdio;
|
|
|
|
class SwitchError : Error
|
|
{
|
|
private:
|
|
|
|
uint linnum;
|
|
char[] filename;
|
|
|
|
this(char[] filename, uint linnum)
|
|
{
|
|
this.linnum = linnum;
|
|
this.filename = filename;
|
|
|
|
char[] buffer = new char[17 + filename.length + linnum.sizeof * 3 + 1];
|
|
int len = sprintf(buffer.ptr, "Switch Default %.*s(%u)", filename, linnum);
|
|
super(cast(string) buffer[0..len]);
|
|
}
|
|
|
|
|
|
public:
|
|
|
|
/***************************************
|
|
* If nobody catches the Assert, this winds up
|
|
* getting called by the startup code.
|
|
*/
|
|
|
|
void print()
|
|
{
|
|
printf("Switch Default %s(%u)\n", cast(char *)filename, linnum);
|
|
}
|
|
}
|
|
|
|
/********************************************
|
|
* Called by the compiler generated module assert function.
|
|
* Builds an Assert exception and throws it.
|
|
*/
|
|
|
|
extern (C) static void _d_switch_error(char[] filename, uint line)
|
|
{
|
|
//printf("_d_switch_error(%s, %d)\n", cast(char *)filename, line);
|
|
SwitchError a = new SwitchError(filename, line);
|
|
//printf("assertion %p created\n", a);
|
|
throw a;
|
|
}
|