Kernel-Exceptions.js 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382
  1. smalltalk.addPackage('Kernel-Exceptions', {});
  2. smalltalk.addClass('Error', smalltalk.Object, ['messageText'], 'Kernel-Exceptions');
  3. smalltalk.addMethod(
  4. "_context",
  5. smalltalk.method({
  6. selector: "context",
  7. category: 'accessing',
  8. fn: function (){
  9. var self=this;
  10. return self.context;
  11. return self;},
  12. args: [],
  13. source: "context\x0a\x09<return self.context>",
  14. messageSends: [],
  15. referencedClasses: []
  16. }),
  17. smalltalk.Error);
  18. smalltalk.addMethod(
  19. "_isSmalltalkError",
  20. smalltalk.method({
  21. selector: "isSmalltalkError",
  22. category: 'testing',
  23. fn: function (){
  24. var self=this;
  25. return self.smalltalkError === true;
  26. return self;},
  27. args: [],
  28. source: "isSmalltalkError\x0a\x09<return self.smalltalkError === true>",
  29. messageSends: [],
  30. referencedClasses: []
  31. }),
  32. smalltalk.Error);
  33. smalltalk.addMethod(
  34. "_jsStack",
  35. smalltalk.method({
  36. selector: "jsStack",
  37. category: 'accessing',
  38. fn: function (){
  39. var self=this;
  40. return self.stack;
  41. return self;},
  42. args: [],
  43. source: "jsStack\x0a\x09<return self.stack>",
  44. messageSends: [],
  45. referencedClasses: []
  46. }),
  47. smalltalk.Error);
  48. smalltalk.addMethod(
  49. "_messageText",
  50. smalltalk.method({
  51. selector: "messageText",
  52. category: 'accessing',
  53. fn: function (){
  54. var self=this;
  55. return self['@messageText'];
  56. return self;},
  57. args: [],
  58. source: "messageText\x0a\x09^messageText",
  59. messageSends: [],
  60. referencedClasses: []
  61. }),
  62. smalltalk.Error);
  63. smalltalk.addMethod(
  64. "_messageText_",
  65. smalltalk.method({
  66. selector: "messageText:",
  67. category: 'accessing',
  68. fn: function (aString){
  69. var self=this;
  70. (self['@messageText']=aString);
  71. return self;},
  72. args: ["aString"],
  73. source: "messageText: aString\x0a\x09messageText := aString",
  74. messageSends: [],
  75. referencedClasses: []
  76. }),
  77. smalltalk.Error);
  78. smalltalk.addMethod(
  79. "_signal",
  80. smalltalk.method({
  81. selector: "signal",
  82. category: 'signaling',
  83. fn: function (){
  84. var self=this;
  85. self.context = smalltalk.getThisContext(); self.smalltalkError = true; throw(self);
  86. return self;},
  87. args: [],
  88. source: "signal\x0a\x09<self.context = smalltalk.getThisContext(); self.smalltalkError = true; throw(self)>",
  89. messageSends: [],
  90. referencedClasses: []
  91. }),
  92. smalltalk.Error);
  93. smalltalk.addMethod(
  94. "_signal_",
  95. smalltalk.method({
  96. selector: "signal:",
  97. category: 'signaling',
  98. fn: function (aString){
  99. var self=this;
  100. smalltalk.send(self, "_messageText_", [aString]);
  101. smalltalk.send(self, "_signal", []);
  102. return self;},
  103. args: ["aString"],
  104. source: "signal: aString\x0a\x09self messageText: aString.\x0a\x09self signal",
  105. messageSends: ["messageText:", "signal"],
  106. referencedClasses: []
  107. }),
  108. smalltalk.Error);
  109. smalltalk.addMethod(
  110. "_signal",
  111. smalltalk.method({
  112. selector: "signal",
  113. category: 'instance creation',
  114. fn: function (){
  115. var self=this;
  116. return smalltalk.send(smalltalk.send(self, "_new", []), "_signal", []);
  117. return self;},
  118. args: [],
  119. source: "signal\x0a\x09^self new signal",
  120. messageSends: ["signal", "new"],
  121. referencedClasses: []
  122. }),
  123. smalltalk.Error.klass);
  124. smalltalk.addMethod(
  125. "_signal_",
  126. smalltalk.method({
  127. selector: "signal:",
  128. category: 'instance creation',
  129. fn: function (aString){
  130. var self=this;
  131. return smalltalk.send(smalltalk.send(self, "_new", []), "_signal_", [aString]);
  132. return self;},
  133. args: ["aString"],
  134. source: "signal: aString\x0a\x09 ^self new\x0a\x09\x09signal: aString",
  135. messageSends: ["signal:", "new"],
  136. referencedClasses: []
  137. }),
  138. smalltalk.Error.klass);
  139. smalltalk.addClass('MessageNotUnderstood', smalltalk.Error, ['message', 'receiver'], 'Kernel-Exceptions');
  140. smalltalk.addMethod(
  141. "_message",
  142. smalltalk.method({
  143. selector: "message",
  144. category: 'accessing',
  145. fn: function (){
  146. var self=this;
  147. return self['@message'];
  148. return self;},
  149. args: [],
  150. source: "message\x0a\x09^message",
  151. messageSends: [],
  152. referencedClasses: []
  153. }),
  154. smalltalk.MessageNotUnderstood);
  155. smalltalk.addMethod(
  156. "_message_",
  157. smalltalk.method({
  158. selector: "message:",
  159. category: 'accessing',
  160. fn: function (aMessage){
  161. var self=this;
  162. (self['@message']=aMessage);
  163. return self;},
  164. args: ["aMessage"],
  165. source: "message: aMessage\x0a\x09message := aMessage",
  166. messageSends: [],
  167. referencedClasses: []
  168. }),
  169. smalltalk.MessageNotUnderstood);
  170. smalltalk.addMethod(
  171. "_messageText",
  172. smalltalk.method({
  173. selector: "messageText",
  174. category: 'accessing',
  175. fn: function (){
  176. var self=this;
  177. return smalltalk.send(smalltalk.send(smalltalk.send(smalltalk.send(self, "_receiver", []), "_asString", []), "__comma", [" does not understand #"]), "__comma", [smalltalk.send(smalltalk.send(self, "_message", []), "_selector", [])]);
  178. return self;},
  179. args: [],
  180. source: "messageText\x0a\x09^self receiver asString, ' does not understand #', self message selector",
  181. messageSends: [",", "asString", "receiver", "selector", "message"],
  182. referencedClasses: []
  183. }),
  184. smalltalk.MessageNotUnderstood);
  185. smalltalk.addMethod(
  186. "_receiver",
  187. smalltalk.method({
  188. selector: "receiver",
  189. category: 'accessing',
  190. fn: function (){
  191. var self=this;
  192. return self['@receiver'];
  193. return self;},
  194. args: [],
  195. source: "receiver\x0a\x09^receiver",
  196. messageSends: [],
  197. referencedClasses: []
  198. }),
  199. smalltalk.MessageNotUnderstood);
  200. smalltalk.addMethod(
  201. "_receiver_",
  202. smalltalk.method({
  203. selector: "receiver:",
  204. category: 'accessing',
  205. fn: function (anObject){
  206. var self=this;
  207. (self['@receiver']=anObject);
  208. return self;},
  209. args: ["anObject"],
  210. source: "receiver: anObject\x0a\x09receiver := anObject",
  211. messageSends: [],
  212. referencedClasses: []
  213. }),
  214. smalltalk.MessageNotUnderstood);
  215. smalltalk.addClass('ErrorHandler', smalltalk.Object, [], 'Kernel-Exceptions');
  216. smalltalk.addMethod(
  217. "_handleError_",
  218. smalltalk.method({
  219. selector: "handleError:",
  220. category: 'error handling',
  221. fn: function (anError){
  222. var self=this;
  223. (($receiver = smalltalk.send(anError, "_context", [])) != nil && $receiver != undefined) ? (function(){return smalltalk.send(self, "_logErrorContext_", [smalltalk.send(anError, "_context", [])]);})() : nil;
  224. smalltalk.send(self, "_logError_", [anError]);
  225. return self;},
  226. args: ["anError"],
  227. source: "handleError: anError\x0a\x09anError context ifNotNil: [self logErrorContext: anError context].\x0a\x09self logError: anError",
  228. messageSends: ["ifNotNil:", "context", "logErrorContext:", "logError:"],
  229. referencedClasses: []
  230. }),
  231. smalltalk.ErrorHandler);
  232. smalltalk.addMethod(
  233. "_log_",
  234. smalltalk.method({
  235. selector: "log:",
  236. category: 'private',
  237. fn: function (aString){
  238. var self=this;
  239. smalltalk.send((typeof console == 'undefined' ? nil : console), "_log_", [aString]);
  240. return self;},
  241. args: ["aString"],
  242. source: "log: aString\x0a\x09console log: aString",
  243. messageSends: ["log:"],
  244. referencedClasses: []
  245. }),
  246. smalltalk.ErrorHandler);
  247. smalltalk.addMethod(
  248. "_logContext_",
  249. smalltalk.method({
  250. selector: "logContext:",
  251. category: 'private',
  252. fn: function (aContext){
  253. var self=this;
  254. (($receiver = smalltalk.send(aContext, "_home", [])) != nil && $receiver != undefined) ? (function(){return smalltalk.send(self, "_logContext_", [smalltalk.send(aContext, "_home", [])]);})() : nil;
  255. smalltalk.send(self, "_log_", [smalltalk.send(smalltalk.send(smalltalk.send(smalltalk.send(aContext, "_receiver", []), "_asString", []), "__comma", [">>"]), "__comma", [smalltalk.send(aContext, "_selector", [])])]);
  256. return self;},
  257. args: ["aContext"],
  258. source: "logContext: aContext\x0a\x09aContext home ifNotNil: [\x0a\x09\x09self logContext: aContext home].\x0a\x09self log: aContext receiver asString, '>>', aContext selector",
  259. messageSends: ["ifNotNil:", "home", "logContext:", "log:", ",", "asString", "receiver", "selector"],
  260. referencedClasses: []
  261. }),
  262. smalltalk.ErrorHandler);
  263. smalltalk.addMethod(
  264. "_logError_",
  265. smalltalk.method({
  266. selector: "logError:",
  267. category: 'private',
  268. fn: function (anError){
  269. var self=this;
  270. smalltalk.send(self, "_log_", [smalltalk.send(anError, "_messageText", [])]);
  271. return self;},
  272. args: ["anError"],
  273. source: "logError: anError\x0a\x09self log: anError messageText",
  274. messageSends: ["log:", "messageText"],
  275. referencedClasses: []
  276. }),
  277. smalltalk.ErrorHandler);
  278. smalltalk.addMethod(
  279. "_logErrorContext_",
  280. smalltalk.method({
  281. selector: "logErrorContext:",
  282. category: 'private',
  283. fn: function (aContext){
  284. var self=this;
  285. (($receiver = aContext) != nil && $receiver != undefined) ? (function(){return (($receiver = smalltalk.send(aContext, "_home", [])) != nil && $receiver != undefined) ? (function(){return smalltalk.send(self, "_logContext_", [smalltalk.send(aContext, "_home", [])]);})() : nil;})() : nil;
  286. return self;},
  287. args: ["aContext"],
  288. source: "logErrorContext: aContext\x0a\x09aContext ifNotNil: [\x0a\x09\x09aContext home ifNotNil: [\x0a\x09\x09\x09self logContext: aContext home]]",
  289. messageSends: ["ifNotNil:", "home", "logContext:"],
  290. referencedClasses: []
  291. }),
  292. smalltalk.ErrorHandler);
  293. smalltalk.ErrorHandler.klass.iVarNames = ['current'];
  294. smalltalk.addMethod(
  295. "_current",
  296. smalltalk.method({
  297. selector: "current",
  298. category: 'accessing',
  299. fn: function (){
  300. var self=this;
  301. return (($receiver = self['@current']) == nil || $receiver == undefined) ? (function(){return (self['@current']=smalltalk.send(self, "_new", []));})() : $receiver;
  302. return self;},
  303. args: [],
  304. source: "current\x0a\x09^current ifNil: [current := self new]",
  305. messageSends: ["ifNil:", "new"],
  306. referencedClasses: []
  307. }),
  308. smalltalk.ErrorHandler.klass);
  309. smalltalk.addMethod(
  310. "_initialize",
  311. smalltalk.method({
  312. selector: "initialize",
  313. category: 'initialization',
  314. fn: function (){
  315. var self=this;
  316. smalltalk.send(self, "_register", []);
  317. return self;},
  318. args: [],
  319. source: "initialize\x0a\x09self register",
  320. messageSends: ["register"],
  321. referencedClasses: []
  322. }),
  323. smalltalk.ErrorHandler.klass);
  324. smalltalk.addMethod(
  325. "_register",
  326. smalltalk.method({
  327. selector: "register",
  328. category: 'initialization',
  329. fn: function (){
  330. var self=this;
  331. smalltalk.send((smalltalk.ErrorHandler || ErrorHandler), "_setCurrent_", [smalltalk.send(self, "_new", [])]);
  332. return self;},
  333. args: [],
  334. source: "register\x0a\x09ErrorHandler setCurrent: self new",
  335. messageSends: ["setCurrent:", "new"],
  336. referencedClasses: ["ErrorHandler"]
  337. }),
  338. smalltalk.ErrorHandler.klass);
  339. smalltalk.addMethod(
  340. "_setCurrent_",
  341. smalltalk.method({
  342. selector: "setCurrent:",
  343. category: 'accessing',
  344. fn: function (anHandler){
  345. var self=this;
  346. (self['@current']=anHandler);
  347. return self;},
  348. args: ["anHandler"],
  349. source: "setCurrent: anHandler\x0a\x09current := anHandler",
  350. messageSends: [],
  351. referencedClasses: []
  352. }),
  353. smalltalk.ErrorHandler.klass);