exceptions.h

Go to the documentation of this file.
00001 /*      Exception.h - exception class for MAXScript
00002  *
00003  *      Copyright (c) John Wainwright, 1996
00004  *      
00005  *
00006  */
00007 
00008 #pragma once
00009 
00010 #include "..\ScripterExport.h"
00011 #include "..\..\strbasic.h"           // MCHAR
00012 #include "..\..\WindowsDefines.h"
00013 class Value;
00014 class Thunk;
00015 class ValueMetaClass;
00016 class CharStream;
00017 
00018 extern MCHAR* null_string;
00019 
00020 class ScripterExport MAXScriptException
00021 {
00022 public:
00023     MAXScriptException() {}
00024     virtual ~MAXScriptException() {}
00025     virtual void sprin1(CharStream* s);
00026 };
00027 
00028 class ScripterExport UnknownSystemException : public MAXScriptException
00029 {
00030 public:
00031             UnknownSystemException() {}
00032     void    sprin1(CharStream* s);
00033 };
00034 
00035 class ScripterExport SignalException : public MAXScriptException
00036 {
00037 public:
00038     void    sprin1(CharStream* s);
00039 };
00040 
00041 class ScripterExport CompileError : public MAXScriptException
00042 {
00043 public:
00044     MCHAR*  description;
00045     MCHAR*  info;
00046     MCHAR*  line;
00047     MCHAR*  file;
00048             CompileError (const MCHAR* d, const MCHAR* i, const MCHAR* l, const MCHAR* f = null_string);
00049             CompileError () { description = NULL; info = null_string; line = null_string; file = null_string; }
00050            ~CompileError ();
00051 
00052     void    sprin1(CharStream* s);
00053     void    set_file(const MCHAR* f);
00054 };
00055 
00056 class ScripterExport SyntaxError : public CompileError
00057 {
00058     MCHAR*  wanted;
00059     MCHAR*  got;
00060 public:
00061             SyntaxError (const MCHAR* w, const MCHAR* g, const MCHAR* l = null_string, const MCHAR* f = null_string);
00062            ~SyntaxError ();
00063 
00064     void    sprin1(CharStream* s);
00065 };
00066 
00067 class ScripterExport TypeError : public MAXScriptException
00068 {
00069     Value*  target;
00070     ValueMetaClass* wanted_class;
00071     MCHAR*  description;
00072 public:
00073             TypeError (const MCHAR* d, Value* t, ValueMetaClass* c = NULL);
00074            ~TypeError ();
00075 
00076     void    sprin1(CharStream* s);
00077 };
00078 
00079 class ScripterExport NoMethodError : public MAXScriptException
00080 {
00081     Value*  target;
00082     MCHAR*  fn_name;
00083 public:
00084             NoMethodError (const MCHAR* fn, Value* t);
00085            ~NoMethodError ();
00086 
00087     void    sprin1(CharStream* s);
00088 };
00089 
00090 #define unimplemented(m, t) throw NoMethodError (m, t)
00091 
00092 class ScripterExport AccessorError : public MAXScriptException
00093 {
00094     Value*  target;
00095     Value*  prop;
00096 public:
00097             AccessorError (Value* t, Value* p) { target = t; prop = p; }
00098 
00099     void    sprin1(CharStream* s);
00100 };
00101 
00102 class ScripterExport AssignToConstError : public MAXScriptException
00103 {
00104     Thunk*  thunk;
00105 public:
00106             AssignToConstError (Thunk* t) { thunk = t; }
00107 
00108     void    sprin1(CharStream* s);
00109 };
00110 
00111 class ScripterExport ArgCountError : public MAXScriptException
00112 {
00113     int     wanted;
00114     int     got;
00115     MCHAR*  fn_name;
00116 public:
00117             ArgCountError (const MCHAR* fn, int w, int g);
00118            ~ArgCountError ();
00119 
00120     void    sprin1(CharStream* s);
00121 };
00122 
00123 class ScripterExport RuntimeError : public MAXScriptException
00124 {
00125 public:
00126             MCHAR*  desc1;
00127             MCHAR*  desc2;
00128             Value*  info;
00129             RuntimeError (const MCHAR* d1);
00130             RuntimeError (const MCHAR* d1, const MCHAR* d2);
00131             RuntimeError (const MCHAR* d1, Value* ii);
00132             RuntimeError (const MCHAR* d1, const MCHAR* d2, Value* ii);
00133             RuntimeError (Value* ii);
00134            ~RuntimeError ();
00135 
00136     void    init(const MCHAR* d1, const MCHAR* d2, Value* ii);
00137     void    sprin1(CharStream* s);
00138 };
00139 
00140 class ScripterExport UserThrownError : public MAXScriptException
00141 {
00142 public:
00143             MCHAR*  desc;
00144             Value*  info;
00145             BOOL    debugBreak;
00146             UserThrownError (const MCHAR* d1, Value* ii, BOOL dbgBreak);
00147             UserThrownError (const MCHAR* di, BOOL dbgBreak);
00148            ~UserThrownError ();
00149 
00150     void    init(const MCHAR* d1, Value* ii, BOOL dbgBreak);
00151     void    sprin1(CharStream* s);
00152 };
00153 
00154 class ScripterExport DebuggerRuntimeError : public MAXScriptException
00155 {
00156 public:
00157     MCHAR*  desc1;
00158     MCHAR*  desc2;
00159     Value*  info;
00160     DebuggerRuntimeError (const MCHAR* d1);
00161     DebuggerRuntimeError (const MCHAR* d1, const MCHAR* d2);
00162     DebuggerRuntimeError (const MCHAR* d1, Value* ii);
00163     DebuggerRuntimeError (const MCHAR* d1, const MCHAR* d2, Value* ii);
00164     DebuggerRuntimeError (Value* ii);
00165     ~DebuggerRuntimeError ();
00166 
00167     void    init(const MCHAR* d1, const MCHAR* d2, Value* ii);
00168     void    sprin1(CharStream* s);
00169 };
00170 
00171 class ScripterExport IncompatibleTypes : public MAXScriptException
00172 {
00173     Value*  val1;
00174     Value*  val2;
00175 public:
00176             IncompatibleTypes (Value* v1, Value* v2) { val1 = v1; val2 = v2; }
00177 
00178     void    sprin1(CharStream* s);
00179 };
00180 
00181 class ScripterExport ConversionError : public MAXScriptException
00182 {
00183     Value*  val;
00184     MCHAR*   type;
00185 public:
00186             ConversionError (Value* v, const MCHAR* t);
00187            ~ConversionError ();
00188 
00189     void    sprin1(CharStream* s);
00190 };
00191 
00192 class FunctionReturn : public MAXScriptException
00193 {
00194 public:
00195     Value*  return_result;
00196             FunctionReturn (Value* v) { return_result = v; }
00197 
00198     void    sprin1(CharStream* s);
00199 };
00200 
00201 class LoopExit : public MAXScriptException
00202 {
00203 public:
00204     Value*  loop_result;
00205             LoopExit (Value* v) { loop_result = v; }
00206 
00207     void    sprin1(CharStream* s);
00208 };
00209 
00210 class LoopContinue : public MAXScriptException
00211 {
00212 public:
00213             LoopContinue () { }
00214 
00215     void    sprin1(CharStream* s);
00216 };
00217