errors.c 3.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. /* Copyright (C) 2005-2010 Valeriy Argunov (nporep AT mail DOT ru) */
  2. /*
  3. * This library is free software; you can redistribute it and/or modify
  4. * it under the terms of the GNU Lesser General Public License as published by
  5. * the Free Software Foundation; either version 2.1 of the License, or
  6. * (at your option) any later version.
  7. *
  8. * This library is distributed in the hope that it will be useful,
  9. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. * GNU Lesser General Public License for more details.
  12. *
  13. * You should have received a copy of the GNU Lesser General Public License
  14. * along with this library; if not, write to the Free Software
  15. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  16. */
  17. #include "errors.h"
  18. int qspErrorNum = 0;
  19. int qspErrorLoc = -1;
  20. int qspErrorLine = 0;
  21. int qspErrorActIndex = -1;
  22. int qspRealCurLoc = -1;
  23. int qspRealLine = 0;
  24. int qspRealActIndex = -1;
  25. void qspSetError(int num)
  26. {
  27. if (!qspErrorNum)
  28. {
  29. qspErrorNum = num;
  30. qspErrorLoc = qspRealCurLoc;
  31. qspErrorActIndex = qspRealActIndex;
  32. qspErrorLine = qspRealLine;
  33. }
  34. }
  35. void qspResetError()
  36. {
  37. qspErrorNum = 0;
  38. qspErrorLoc = -1;
  39. qspErrorActIndex = -1;
  40. qspErrorLine = 0;
  41. }
  42. QSP_CHAR *qspGetErrorDesc(int errorNum)
  43. {
  44. QSP_CHAR *str;
  45. switch (errorNum)
  46. {
  47. case QSP_ERR_DIVBYZERO: str = QSP_FMT("Division by zero!"); break;
  48. case QSP_ERR_TYPEMISMATCH: str = QSP_FMT("Type mismatch!"); break;
  49. case QSP_ERR_STACKOVERFLOW: str = QSP_FMT("Stack overflow!"); break;
  50. case QSP_ERR_TOOMANYITEMS: str = QSP_FMT("Too many items in expression!"); break;
  51. case QSP_ERR_FILENOTFOUND: str = QSP_FMT("File not found!"); break;
  52. case QSP_ERR_CANTLOADFILE: str = QSP_FMT("Can't load file!"); break;
  53. case QSP_ERR_GAMENOTLOADED: str = QSP_FMT("Game not loaded!"); break;
  54. case QSP_ERR_COLONNOTFOUND: str = QSP_FMT("Sign [:] not found!"); break;
  55. case QSP_ERR_CANTINCFILE: str = QSP_FMT("Can't add file!"); break;
  56. case QSP_ERR_CANTADDACTION: str = QSP_FMT("Can't add action!"); break;
  57. case QSP_ERR_EQNOTFOUND: str = QSP_FMT("Sign [=] not found!"); break;
  58. case QSP_ERR_LOCNOTFOUND: str = QSP_FMT("Location not found!"); break;
  59. case QSP_ERR_ENDNOTFOUND: str = QSP_FMT("[end] not found!"); break;
  60. case QSP_ERR_LABELNOTFOUND: str = QSP_FMT("Label not found!"); break;
  61. case QSP_ERR_NOTCORRECTNAME: str = QSP_FMT("Incorrect variable's name!"); break;
  62. case QSP_ERR_QUOTNOTFOUND: str = QSP_FMT("Quote not found!"); break;
  63. case QSP_ERR_BRACKNOTFOUND: str = QSP_FMT("Bracket not found!"); break;
  64. case QSP_ERR_BRACKSNOTFOUND: str = QSP_FMT("Brackets not found!"); break;
  65. case QSP_ERR_SYNTAX: str = QSP_FMT("Syntax error!"); break;
  66. case QSP_ERR_UNKNOWNACTION: str = QSP_FMT("Unknown action!"); break;
  67. case QSP_ERR_ARGSCOUNT: str = QSP_FMT("Incorrect arguments' count!"); break;
  68. case QSP_ERR_CANTADDOBJECT: str = QSP_FMT("Can't add object!"); break;
  69. case QSP_ERR_CANTADDMENUITEM: str = QSP_FMT("Can't add menu's item!"); break;
  70. case QSP_ERR_TOOMANYVARS: str = QSP_FMT("Too many variables!"); break;
  71. case QSP_ERR_INCORRECTREGEXP: str = QSP_FMT("Regular expression's error!"); break;
  72. case QSP_ERR_CODENOTFOUND: str = QSP_FMT("Code not found!"); break;
  73. case QSP_ERR_TONOTFOUND: str = QSP_FMT("[to] not found!"); break;
  74. default: str = QSP_FMT("Unknown error!"); break;
  75. }
  76. return str;
  77. }