diff options
Diffstat (limited to 'src/sdlang/exception.d')
-rw-r--r-- | src/sdlang/exception.d | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/src/sdlang/exception.d b/src/sdlang/exception.d new file mode 100644 index 0000000..e87307f --- /dev/null +++ b/src/sdlang/exception.d @@ -0,0 +1,42 @@ +// SDLang-D +// Written in the D programming language. + +module sdlang.exception; + +import std.exception; +import std.string; + +import sdlang.util; + +abstract class SDLangException : Exception +{ + this(string msg) { super(msg); } +} + +class SDLangParseException : SDLangException +{ + Location location; + bool hasLocation; + + this(string msg) + { + hasLocation = false; + super(msg); + } + + this(Location location, string msg) + { + hasLocation = true; + super("%s: %s".format(location.toString(), msg)); + } +} + +class SDLangValidationException : SDLangException +{ + this(string msg) { super(msg); } +} + +class SDLangRangeException : SDLangException +{ + this(string msg) { super(msg); } +} |