1
0
Files
otyaSMILEBASIC/SMILEBASIC/error.d

277 lines
5.0 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;
2016-12-23 19:37:33 +09:00
import otya.smilebasic.token;
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;
2016-12-23 21:09:38 +09:00
string func;
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
}
2016-12-29 16:16:56 +09:00
class InternalError : SmileBasicError
{
this()
{
this.errnum = 1;
super("Internal Error");
}
}
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
{
2016-12-23 19:25:55 +09:00
this()
{
this.errnum = 4;
super("Illegal function call");
}
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-06 18:39:56 +09:00
this(string func, int arg)
{
this.errnum = 4;
super("Illegal function call(" ~ func ~ ":" ~ arg.to!string ~ ")");
}
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");
}
2016-12-08 20:41:46 +09:00
this(string func)
{
this.errnum = 8;
super("Type mismatch(" ~ func ~ ")");
}
this(string func, int arg)
{
this.errnum = 8;
super("Type mismatch(" ~ func ~ ":" ~ arg.to!string ~ ")");
}
2015-06-07 19:11:18 +09:00
}
class OutOfRange : SmileBasicError
{
this()
{
this.errnum = 10;
super("Out of range");
}
2016-12-04 21:57:07 +09:00
this(string func)
{
this.errnum = 10;
super("Out of range(" ~ func ~ ")");
}
2016-12-04 17:27:51 +09:00
this(string func, int arg)
{
this.errnum = 10;
super("Out of range(" ~ func ~ ":" ~ arg.to!string ~ ")");
}
}
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");
}
}
2016-12-29 15:37:28 +09:00
class UndefinedFunction : SmileBasicError
{
this()
{
this.errnum = 16;
super("Undefined function");
}
this(wstring name)
{
this();
}
}
2015-06-07 19:11:18 +09:00
class DuplicateVariable : SmileBasicError
{
this()
{
this.errnum = 18;
super("Duplicate variable");
}
}
2016-12-23 19:37:33 +09:00
class DuplicateFunction : SmileBasicError
{
this(int slot, SourceLocation loc)
{
this.errnum = 19;
super(slot, loc.line, "Duplicate function");
}
}
class ReturnWithoutGosub : SmileBasicError
{
this()
{
this.errnum = 30;
super("RETURN without GOSUB");
}
}
class SubscriptOutOfRange : SmileBasicError
{
this()
{
this.errnum = 31;
super("Subscript out of range");
}
2016-12-14 17:50:06 +09:00
this(string func)
{
this.errnum = 31;
super("Subscript out of range(" ~ func ~ ")");
}
this(string func, int arg)
{
this.errnum = 31;
super("Subscript out of range(" ~ func ~ ":" ~ arg.to!string ~ ")");
}
}
2016-12-29 16:16:56 +09:00
class IllegalSymbolString : SmileBasicError
{
this()
{
this.errnum = 34;
super("Illegal symbol string");
}
}
class UsePRGEDITBeforeAnyPRGFunction : SmileBasicError
{
this(string func)
{
this.errnum = 38;
super("Use PRGEDIT before any PRG function(" ~ func ~ ")");
}
}
2016-12-08 20:01:40 +09:00
class StringTooLong : SmileBasicError
{
this()
{
this.errnum = 41;
super("String too long");
}
this(string func)
{
this.errnum = 41;
super("String too long(" ~ func ~ ")");
}
this(string func, int arg)
{
this.errnum = 41;
super("String too long(" ~ func ~ ":" ~ arg.to!string ~ ")");
}
}
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");
}
}
2016-12-23 17:22:32 +09:00
class LoadFailed : SmileBasicError
{
this()
{
this.errnum = 46;
super("Load failed");
}
}