1
0
Files
otyaSMILEBASIC/SMILEBASIC/error.d

162 lines
2.7 KiB
D
Raw Normal View History

2015-06-07 19:11:18 +09:00
module otya.smilebasic.error;
import std.exception;
import std.string;
2015-08-22 22:16:13 +09:00
import std.conv;
2015-06-07 19:11:18 +09:00
class SmileBasicError : Exception
{
int errnum;
int errline;
int errprg;
2015-08-22 22:16:13 +09:00
string message2;
2015-06-07 19:11:18 +09:00
this(int slot, int line, string message)
{
super(format("%s in %d:%d", message, slot, line));
}
this(int line, string message)
{
super(format("%s in %d", message, line));
}
this(string message)
{
super(message);
}
2015-08-22 22:16:13 +09:00
this(string message, string message2)
{
super(message);
this.message2 = message2;
}
string getErrorMessage()
{
return this.msg;
}
//詳細
string getErrorMessage2()
{
return message2;
}
2015-06-07 19:11:18 +09:00
}
class SyntaxError : SmileBasicError
{
this()
{
this.errnum = 3;
super("Syntax error");
}
2015-08-22 22:16:13 +09:00
this(wstring func)
{
this();
this.message2 = "Undefined function (" ~ func.to!string ~ ")";
2015-08-22 22:16:13 +09:00
}
}
2015-06-13 20:21:11 +09:00
class IllegalFunctionCall : SmileBasicError
{
2015-08-22 22:16:13 +09:00
this(string func)
2015-06-13 20:21:11 +09:00
{
this.errnum = 4;
2015-08-22 22:16:13 +09:00
super("Illegal function call(" ~ func ~ ")");
2015-06-13 20:21:11 +09:00
}
}
2016-12-04 16:25:12 +09:00
class StackOverFlow : SmileBasicError
{
this()
{
this.errnum = 5;
super("Stack overflow");
}
}
class StackUnderFlow : SmileBasicError
{
this()
{
this.errnum = 6;
super("Stack underflow");
}
}
2015-06-07 19:11:18 +09:00
class TypeMismatch : SmileBasicError
{
this()
{
this.errnum = 8;
super("Type mismatch");
}
}
class OutOfRange : SmileBasicError
{
this()
{
this.errnum = 10;
super("Out of range");
}
}
2015-08-19 13:02:02 +09:00
class OutOfDATA : SmileBasicError
{
this()
{
this.errnum = 13;
super("Out of DATA");
}
}
2016-12-04 16:30:31 +09:00
class UndefinedLabel : SmileBasicError
{
this()
{
this.errnum = 14;
super("Undefined label");
}
this(wstring label)
{
this();
}
}
2016-09-02 20:57:36 +09:00
class UndefinedVariable : SmileBasicError
{
this()
{
this.errnum = 15;
super("Undefined variable");
}
}
2015-06-07 19:11:18 +09:00
class DuplicateVariable : SmileBasicError
{
this()
{
this.errnum = 18;
super("Duplicate variable");
}
}
class ReturnWithoutGosub : SmileBasicError
{
this()
{
this.errnum = 30;
super("RETURN without GOSUB");
}
}
class SubscriptOutOfRange : SmileBasicError
{
this()
{
this.errnum = 31;
super("Subscript out of range");
}
}
2016-02-22 23:08:54 +09:00
class CantUseFromDirectMode : SmileBasicError
{
this()
{
this.errnum = 43;
this.errprg = 0;//always 0
this.errline = 0;
super("Can't use from direct mode");
}
}
2016-02-23 23:05:24 +09:00
class CantUseInProgram : SmileBasicError
{
this(wstring func)
{
this.errnum = 44;
super("Can't use in program");
}
}