Kernel-Exceptions.js 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813
  1. define("amber_core/Kernel-Exceptions", ["amber/boot", "amber_core/Kernel-Objects"], function($boot){"use strict";
  2. var $core=$boot.api,nil=$boot.nil,$recv=$boot.asReceiver,$globals=$boot.globals;
  3. $core.addPackage('Kernel-Exceptions');
  4. $core.packages["Kernel-Exceptions"].innerEval = function (expr) { return eval(expr); };
  5. $core.packages["Kernel-Exceptions"].transport = {"type":"amd","amdNamespace":"amber_core"};
  6. $core.addClass('Error', $globals.Object, ['messageText'], 'Kernel-Exceptions');
  7. //>>excludeStart("ide", pragmas.excludeIdeData);
  8. $globals.Error.comment="From the ANSI standard:\x0a\x0aThis protocol describes the behavior of instances of class `Error`.\x0aThese are used to represent error conditions that prevent the normal continuation of processing.\x0aActual error exceptions used by an application may be subclasses of this class.\x0aAs `Error` is explicitly specified to be subclassable, conforming implementations must implement its behavior in a non-fragile manner.";
  9. //>>excludeEnd("ide");
  10. $core.addMethod(
  11. $core.method({
  12. selector: "beHandled",
  13. protocol: 'accessing',
  14. fn: function (){
  15. var self=this;
  16. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  17. return $core.withContext(function($ctx1) {
  18. //>>excludeEnd("ctx");
  19. self.amberHandled = true;
  20. return self;
  21. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  22. }, function($ctx1) {$ctx1.fill(self,"beHandled",{},$globals.Error)});
  23. //>>excludeEnd("ctx");
  24. },
  25. //>>excludeStart("ide", pragmas.excludeIdeData);
  26. args: [],
  27. source: "beHandled\x0a\x09<self.amberHandled = true>",
  28. referencedClasses: [],
  29. //>>excludeEnd("ide");
  30. messageSends: []
  31. }),
  32. $globals.Error);
  33. $core.addMethod(
  34. $core.method({
  35. selector: "beUnhandled",
  36. protocol: 'accessing',
  37. fn: function (){
  38. var self=this;
  39. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  40. return $core.withContext(function($ctx1) {
  41. //>>excludeEnd("ctx");
  42. self.amberHandled = false;
  43. return self;
  44. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  45. }, function($ctx1) {$ctx1.fill(self,"beUnhandled",{},$globals.Error)});
  46. //>>excludeEnd("ctx");
  47. },
  48. //>>excludeStart("ide", pragmas.excludeIdeData);
  49. args: [],
  50. source: "beUnhandled\x0a\x09<self.amberHandled = false>",
  51. referencedClasses: [],
  52. //>>excludeEnd("ide");
  53. messageSends: []
  54. }),
  55. $globals.Error);
  56. $core.addMethod(
  57. $core.method({
  58. selector: "context",
  59. protocol: 'accessing',
  60. fn: function (){
  61. var self=this;
  62. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  63. return $core.withContext(function($ctx1) {
  64. //>>excludeEnd("ctx");
  65. return self.context;
  66. return self;
  67. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  68. }, function($ctx1) {$ctx1.fill(self,"context",{},$globals.Error)});
  69. //>>excludeEnd("ctx");
  70. },
  71. //>>excludeStart("ide", pragmas.excludeIdeData);
  72. args: [],
  73. source: "context\x0a\x09<return self.context>",
  74. referencedClasses: [],
  75. //>>excludeEnd("ide");
  76. messageSends: []
  77. }),
  78. $globals.Error);
  79. $core.addMethod(
  80. $core.method({
  81. selector: "initialize",
  82. protocol: 'initialization',
  83. fn: function (){
  84. var self=this;
  85. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  86. return $core.withContext(function($ctx1) {
  87. //>>excludeEnd("ctx");
  88. self._messageText_("Errorclass: ".__comma($recv(self._class())._name()));
  89. return self;
  90. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  91. }, function($ctx1) {$ctx1.fill(self,"initialize",{},$globals.Error)});
  92. //>>excludeEnd("ctx");
  93. },
  94. //>>excludeStart("ide", pragmas.excludeIdeData);
  95. args: [],
  96. source: "initialize\x0a\x09self messageText: 'Errorclass: ', (self class name).",
  97. referencedClasses: [],
  98. //>>excludeEnd("ide");
  99. messageSends: ["messageText:", ",", "name", "class"]
  100. }),
  101. $globals.Error);
  102. $core.addMethod(
  103. $core.method({
  104. selector: "isSmalltalkError",
  105. protocol: 'testing',
  106. fn: function (){
  107. var self=this;
  108. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  109. return $core.withContext(function($ctx1) {
  110. //>>excludeEnd("ctx");
  111. return self.smalltalkError === true;
  112. return self;
  113. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  114. }, function($ctx1) {$ctx1.fill(self,"isSmalltalkError",{},$globals.Error)});
  115. //>>excludeEnd("ctx");
  116. },
  117. //>>excludeStart("ide", pragmas.excludeIdeData);
  118. args: [],
  119. source: "isSmalltalkError\x0a\x09<return self.smalltalkError === true>",
  120. referencedClasses: [],
  121. //>>excludeEnd("ide");
  122. messageSends: []
  123. }),
  124. $globals.Error);
  125. $core.addMethod(
  126. $core.method({
  127. selector: "jsStack",
  128. protocol: 'accessing',
  129. fn: function (){
  130. var self=this;
  131. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  132. return $core.withContext(function($ctx1) {
  133. //>>excludeEnd("ctx");
  134. return self.stack;
  135. return self;
  136. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  137. }, function($ctx1) {$ctx1.fill(self,"jsStack",{},$globals.Error)});
  138. //>>excludeEnd("ctx");
  139. },
  140. //>>excludeStart("ide", pragmas.excludeIdeData);
  141. args: [],
  142. source: "jsStack\x0a\x09<return self.stack>",
  143. referencedClasses: [],
  144. //>>excludeEnd("ide");
  145. messageSends: []
  146. }),
  147. $globals.Error);
  148. $core.addMethod(
  149. $core.method({
  150. selector: "messageText",
  151. protocol: 'accessing',
  152. fn: function (){
  153. var self=this;
  154. return self["@messageText"];
  155. },
  156. //>>excludeStart("ide", pragmas.excludeIdeData);
  157. args: [],
  158. source: "messageText\x0a\x09^ messageText",
  159. referencedClasses: [],
  160. //>>excludeEnd("ide");
  161. messageSends: []
  162. }),
  163. $globals.Error);
  164. $core.addMethod(
  165. $core.method({
  166. selector: "messageText:",
  167. protocol: 'accessing',
  168. fn: function (aString){
  169. var self=this;
  170. self["@messageText"]=aString;
  171. return self;
  172. },
  173. //>>excludeStart("ide", pragmas.excludeIdeData);
  174. args: ["aString"],
  175. source: "messageText: aString\x0a\x09messageText := aString",
  176. referencedClasses: [],
  177. //>>excludeEnd("ide");
  178. messageSends: []
  179. }),
  180. $globals.Error);
  181. $core.addMethod(
  182. $core.method({
  183. selector: "resignal",
  184. protocol: 'signaling',
  185. fn: function (){
  186. var self=this;
  187. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  188. return $core.withContext(function($ctx1) {
  189. //>>excludeEnd("ctx");
  190. self.amberHandled = false;
  191. throw(self);
  192. ;
  193. return self;
  194. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  195. }, function($ctx1) {$ctx1.fill(self,"resignal",{},$globals.Error)});
  196. //>>excludeEnd("ctx");
  197. },
  198. //>>excludeStart("ide", pragmas.excludeIdeData);
  199. args: [],
  200. source: "resignal\x0a\x09\x22Resignal the receiver without changing its exception context\x22\x0a\x09\x0a\x09<\x0a\x09\x09self.amberHandled = false;\x0a\x09\x09throw(self);\x0a\x09>",
  201. referencedClasses: [],
  202. //>>excludeEnd("ide");
  203. messageSends: []
  204. }),
  205. $globals.Error);
  206. $core.addMethod(
  207. $core.method({
  208. selector: "signal",
  209. protocol: 'signaling',
  210. fn: function (){
  211. var self=this;
  212. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  213. return $core.withContext(function($ctx1) {
  214. //>>excludeEnd("ctx");
  215. self.amberHandled = false;
  216. self.context = $core.getThisContext();
  217. self.smalltalkError = true;
  218. throw self;
  219. ;
  220. return self;
  221. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  222. }, function($ctx1) {$ctx1.fill(self,"signal",{},$globals.Error)});
  223. //>>excludeEnd("ctx");
  224. },
  225. //>>excludeStart("ide", pragmas.excludeIdeData);
  226. args: [],
  227. source: "signal\x0a\x09<\x0a\x09\x09self.amberHandled = false;\x0a\x09\x09self.context = $core.getThisContext(); \x0a\x09\x09self.smalltalkError = true;\x0a\x09\x09throw self;\x0a\x09>",
  228. referencedClasses: [],
  229. //>>excludeEnd("ide");
  230. messageSends: []
  231. }),
  232. $globals.Error);
  233. $core.addMethod(
  234. $core.method({
  235. selector: "signal:",
  236. protocol: 'signaling',
  237. fn: function (aString){
  238. var self=this;
  239. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  240. return $core.withContext(function($ctx1) {
  241. //>>excludeEnd("ctx");
  242. self._messageText_(aString);
  243. self._signal();
  244. return self;
  245. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  246. }, function($ctx1) {$ctx1.fill(self,"signal:",{aString:aString},$globals.Error)});
  247. //>>excludeEnd("ctx");
  248. },
  249. //>>excludeStart("ide", pragmas.excludeIdeData);
  250. args: ["aString"],
  251. source: "signal: aString\x0a\x09self messageText: aString.\x0a\x09self signal",
  252. referencedClasses: [],
  253. //>>excludeEnd("ide");
  254. messageSends: ["messageText:", "signal"]
  255. }),
  256. $globals.Error);
  257. $core.addMethod(
  258. $core.method({
  259. selector: "signalerContext",
  260. protocol: 'accessing',
  261. fn: function (){
  262. var self=this;
  263. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  264. return $core.withContext(function($ctx1) {
  265. //>>excludeEnd("ctx");
  266. return self._signalerContextFrom_(self._context());
  267. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  268. }, function($ctx1) {$ctx1.fill(self,"signalerContext",{},$globals.Error)});
  269. //>>excludeEnd("ctx");
  270. },
  271. //>>excludeStart("ide", pragmas.excludeIdeData);
  272. args: [],
  273. source: "signalerContext\x0a\x09^ self signalerContextFrom: self context",
  274. referencedClasses: [],
  275. //>>excludeEnd("ide");
  276. messageSends: ["signalerContextFrom:", "context"]
  277. }),
  278. $globals.Error);
  279. $core.addMethod(
  280. $core.method({
  281. selector: "signalerContextFrom:",
  282. protocol: 'accessing',
  283. fn: function (aContext){
  284. var self=this;
  285. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  286. return $core.withContext(function($ctx1) {
  287. //>>excludeEnd("ctx");
  288. var $3,$2,$1;
  289. return $recv(aContext)._findContextSuchThat_((function(context){
  290. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  291. return $core.withContext(function($ctx2) {
  292. //>>excludeEnd("ctx");
  293. $3=$recv(context)._receiver();
  294. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  295. $ctx2.sendIdx["receiver"]=1;
  296. //>>excludeEnd("ctx");
  297. $2=$recv($3).__eq_eq(self);
  298. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  299. $ctx2.sendIdx["=="]=1;
  300. //>>excludeEnd("ctx");
  301. $1=$recv($2)._or_((function(){
  302. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  303. return $core.withContext(function($ctx3) {
  304. //>>excludeEnd("ctx");
  305. return $recv($recv(context)._receiver()).__eq_eq(self._class());
  306. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  307. }, function($ctx3) {$ctx3.fillBlock({},$ctx2,2)});
  308. //>>excludeEnd("ctx");
  309. }));
  310. return $recv($1)._not();
  311. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  312. }, function($ctx2) {$ctx2.fillBlock({context:context},$ctx1,1)});
  313. //>>excludeEnd("ctx");
  314. }));
  315. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  316. }, function($ctx1) {$ctx1.fill(self,"signalerContextFrom:",{aContext:aContext},$globals.Error)});
  317. //>>excludeEnd("ctx");
  318. },
  319. //>>excludeStart("ide", pragmas.excludeIdeData);
  320. args: ["aContext"],
  321. source: "signalerContextFrom: aContext\x0a\x09\x22Find the first sender of signal(:), the first context which is neither \x0a\x09for an instance method nor for a class side method of Exception (or subclass).\x0a\x09This will make sure that the same context is found for both, `Error signal` \x0a\x09and `Error new signal`\x22\x0a\x0a\x09^ aContext findContextSuchThat: [ :context |\x0a\x09\x09(context receiver == self \x0a\x09\x09or: [ context receiver == self class ]) not ]",
  322. referencedClasses: [],
  323. //>>excludeEnd("ide");
  324. messageSends: ["findContextSuchThat:", "not", "or:", "==", "receiver", "class"]
  325. }),
  326. $globals.Error);
  327. $core.addMethod(
  328. $core.method({
  329. selector: "wasHandled",
  330. protocol: 'testing',
  331. fn: function (){
  332. var self=this;
  333. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  334. return $core.withContext(function($ctx1) {
  335. //>>excludeEnd("ctx");
  336. return self.amberHandled || false;
  337. return self;
  338. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  339. }, function($ctx1) {$ctx1.fill(self,"wasHandled",{},$globals.Error)});
  340. //>>excludeEnd("ctx");
  341. },
  342. //>>excludeStart("ide", pragmas.excludeIdeData);
  343. args: [],
  344. source: "wasHandled\x0a\x09<return self.amberHandled || false>",
  345. referencedClasses: [],
  346. //>>excludeEnd("ide");
  347. messageSends: []
  348. }),
  349. $globals.Error);
  350. $core.addMethod(
  351. $core.method({
  352. selector: "classTag",
  353. protocol: 'accessing',
  354. fn: function (){
  355. var self=this;
  356. return "exception";
  357. },
  358. //>>excludeStart("ide", pragmas.excludeIdeData);
  359. args: [],
  360. source: "classTag\x0a\x09\x22Returns a tag or general category for this class.\x0a\x09Typically used to help tools do some reflection.\x0a\x09Helios, for example, uses this to decide what icon the class should display.\x22\x0a\x09\x0a\x09^ 'exception'",
  361. referencedClasses: [],
  362. //>>excludeEnd("ide");
  363. messageSends: []
  364. }),
  365. $globals.Error.klass);
  366. $core.addMethod(
  367. $core.method({
  368. selector: "signal",
  369. protocol: 'instance creation',
  370. fn: function (){
  371. var self=this;
  372. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  373. return $core.withContext(function($ctx1) {
  374. //>>excludeEnd("ctx");
  375. return $recv(self._new())._signal();
  376. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  377. }, function($ctx1) {$ctx1.fill(self,"signal",{},$globals.Error.klass)});
  378. //>>excludeEnd("ctx");
  379. },
  380. //>>excludeStart("ide", pragmas.excludeIdeData);
  381. args: [],
  382. source: "signal\x0a\x09^ self new signal",
  383. referencedClasses: [],
  384. //>>excludeEnd("ide");
  385. messageSends: ["signal", "new"]
  386. }),
  387. $globals.Error.klass);
  388. $core.addMethod(
  389. $core.method({
  390. selector: "signal:",
  391. protocol: 'instance creation',
  392. fn: function (aString){
  393. var self=this;
  394. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  395. return $core.withContext(function($ctx1) {
  396. //>>excludeEnd("ctx");
  397. return $recv(self._new())._signal_(aString);
  398. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  399. }, function($ctx1) {$ctx1.fill(self,"signal:",{aString:aString},$globals.Error.klass)});
  400. //>>excludeEnd("ctx");
  401. },
  402. //>>excludeStart("ide", pragmas.excludeIdeData);
  403. args: ["aString"],
  404. source: "signal: aString\x0a\x09^ self new\x0a\x09\x09signal: aString",
  405. referencedClasses: [],
  406. //>>excludeEnd("ide");
  407. messageSends: ["signal:", "new"]
  408. }),
  409. $globals.Error.klass);
  410. $core.addClass('Halt', $globals.Error, [], 'Kernel-Exceptions');
  411. //>>excludeStart("ide", pragmas.excludeIdeData);
  412. $globals.Halt.comment="I am provided to support `Object>>#halt`.";
  413. //>>excludeEnd("ide");
  414. $core.addMethod(
  415. $core.method({
  416. selector: "messageText",
  417. protocol: 'accessing',
  418. fn: function (){
  419. var self=this;
  420. return "Halt encountered";
  421. },
  422. //>>excludeStart("ide", pragmas.excludeIdeData);
  423. args: [],
  424. source: "messageText\x0a\x09^ 'Halt encountered'",
  425. referencedClasses: [],
  426. //>>excludeEnd("ide");
  427. messageSends: []
  428. }),
  429. $globals.Halt);
  430. $core.addMethod(
  431. $core.method({
  432. selector: "signalerContextFrom:",
  433. protocol: 'accessing',
  434. fn: function (aContext){
  435. var self=this;
  436. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  437. return $core.withContext(function($ctx1) {
  438. //>>excludeEnd("ctx");
  439. var $3,$2,$1;
  440. return $recv(aContext)._findContextSuchThat_((function(context){
  441. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  442. return $core.withContext(function($ctx2) {
  443. //>>excludeEnd("ctx");
  444. $3=$recv(context)._receiver();
  445. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  446. $ctx2.sendIdx["receiver"]=1;
  447. //>>excludeEnd("ctx");
  448. $2=$recv($3).__eq_eq(self);
  449. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  450. $ctx2.sendIdx["=="]=1;
  451. //>>excludeEnd("ctx");
  452. $1=$recv($2)._or_((function(){
  453. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  454. return $core.withContext(function($ctx3) {
  455. //>>excludeEnd("ctx");
  456. return $recv($recv($recv(context)._receiver()).__eq_eq(self._class()))._or_((function(){
  457. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  458. return $core.withContext(function($ctx4) {
  459. //>>excludeEnd("ctx");
  460. return $recv($recv($recv(context)._method())._selector()).__eq("halt");
  461. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  462. }, function($ctx4) {$ctx4.fillBlock({},$ctx3,3)});
  463. //>>excludeEnd("ctx");
  464. }));
  465. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  466. }, function($ctx3) {$ctx3.fillBlock({},$ctx2,2)});
  467. //>>excludeEnd("ctx");
  468. }));
  469. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  470. $ctx2.sendIdx["or:"]=1;
  471. //>>excludeEnd("ctx");
  472. return $recv($1)._not();
  473. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  474. }, function($ctx2) {$ctx2.fillBlock({context:context},$ctx1,1)});
  475. //>>excludeEnd("ctx");
  476. }));
  477. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  478. }, function($ctx1) {$ctx1.fill(self,"signalerContextFrom:",{aContext:aContext},$globals.Halt)});
  479. //>>excludeEnd("ctx");
  480. },
  481. //>>excludeStart("ide", pragmas.excludeIdeData);
  482. args: ["aContext"],
  483. source: "signalerContextFrom: aContext\x0a\x09\x22specialized version to find the proper context to open the debugger on.\x0a\x09This will find the first context whose method is no longer on `Halt` or \x0a\x09`Halt class` nor is `#halt` method itself.\x22\x0a\x09\x0a\x09^ aContext findContextSuchThat: [ :context |\x0a\x09\x09(context receiver == self \x0a\x09\x09or: [ (context receiver == self class) \x0a\x09\x09or: [ context method selector = #halt ]]) not ]",
  484. referencedClasses: [],
  485. //>>excludeEnd("ide");
  486. messageSends: ["findContextSuchThat:", "not", "or:", "==", "receiver", "class", "=", "selector", "method"]
  487. }),
  488. $globals.Halt);
  489. $core.addClass('JavaScriptException', $globals.Error, ['exception'], 'Kernel-Exceptions');
  490. //>>excludeStart("ide", pragmas.excludeIdeData);
  491. $globals.JavaScriptException.comment="A JavaScriptException is thrown when a non-Smalltalk exception occurs while in the Smalltalk stack.\x0aSee `boot.js` `inContext()` and `BlockClosure >> on:do:`";
  492. //>>excludeEnd("ide");
  493. $core.addMethod(
  494. $core.method({
  495. selector: "context:",
  496. protocol: 'accessing',
  497. fn: function (aMethodContext){
  498. var self=this;
  499. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  500. return $core.withContext(function($ctx1) {
  501. //>>excludeEnd("ctx");
  502. self.context = aMethodContext;
  503. return self;
  504. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  505. }, function($ctx1) {$ctx1.fill(self,"context:",{aMethodContext:aMethodContext},$globals.JavaScriptException)});
  506. //>>excludeEnd("ctx");
  507. },
  508. //>>excludeStart("ide", pragmas.excludeIdeData);
  509. args: ["aMethodContext"],
  510. source: "context: aMethodContext\x0a\x09\x22Set the context from the outside.\x0a\x09See boot.js `inContext()` exception handling\x22\x0a\x09\x0a\x09<self.context = aMethodContext>",
  511. referencedClasses: [],
  512. //>>excludeEnd("ide");
  513. messageSends: []
  514. }),
  515. $globals.JavaScriptException);
  516. $core.addMethod(
  517. $core.method({
  518. selector: "exception",
  519. protocol: 'accessing',
  520. fn: function (){
  521. var self=this;
  522. return self["@exception"];
  523. },
  524. //>>excludeStart("ide", pragmas.excludeIdeData);
  525. args: [],
  526. source: "exception\x0a\x09^ exception",
  527. referencedClasses: [],
  528. //>>excludeEnd("ide");
  529. messageSends: []
  530. }),
  531. $globals.JavaScriptException);
  532. $core.addMethod(
  533. $core.method({
  534. selector: "exception:",
  535. protocol: 'accessing',
  536. fn: function (anException){
  537. var self=this;
  538. self["@exception"]=anException;
  539. return self;
  540. },
  541. //>>excludeStart("ide", pragmas.excludeIdeData);
  542. args: ["anException"],
  543. source: "exception: anException\x0a\x09exception := anException",
  544. referencedClasses: [],
  545. //>>excludeEnd("ide");
  546. messageSends: []
  547. }),
  548. $globals.JavaScriptException);
  549. $core.addMethod(
  550. $core.method({
  551. selector: "messageText",
  552. protocol: 'accessing',
  553. fn: function (){
  554. var self=this;
  555. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  556. return $core.withContext(function($ctx1) {
  557. //>>excludeEnd("ctx");
  558. return 'JavaScript exception: ' + self["@exception"].toString();
  559. return self;
  560. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  561. }, function($ctx1) {$ctx1.fill(self,"messageText",{},$globals.JavaScriptException)});
  562. //>>excludeEnd("ctx");
  563. },
  564. //>>excludeStart("ide", pragmas.excludeIdeData);
  565. args: [],
  566. source: "messageText\x0a\x09<return 'JavaScript exception: ' + self[\x22@exception\x22].toString()>",
  567. referencedClasses: [],
  568. //>>excludeEnd("ide");
  569. messageSends: []
  570. }),
  571. $globals.JavaScriptException);
  572. $core.addMethod(
  573. $core.method({
  574. selector: "on:",
  575. protocol: 'instance creation',
  576. fn: function (anException){
  577. var self=this;
  578. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  579. return $core.withContext(function($ctx1) {
  580. //>>excludeEnd("ctx");
  581. var $1;
  582. $1=self._new();
  583. $recv($1)._exception_(anException);
  584. return $recv($1)._yourself();
  585. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  586. }, function($ctx1) {$ctx1.fill(self,"on:",{anException:anException},$globals.JavaScriptException.klass)});
  587. //>>excludeEnd("ctx");
  588. },
  589. //>>excludeStart("ide", pragmas.excludeIdeData);
  590. args: ["anException"],
  591. source: "on: anException\x0a\x09^ self new\x0a\x09\x09exception: anException;\x0a\x09\x09yourself",
  592. referencedClasses: [],
  593. //>>excludeEnd("ide");
  594. messageSends: ["exception:", "new", "yourself"]
  595. }),
  596. $globals.JavaScriptException.klass);
  597. $core.addMethod(
  598. $core.method({
  599. selector: "on:context:",
  600. protocol: 'instance creation',
  601. fn: function (anException,aMethodContext){
  602. var self=this;
  603. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  604. return $core.withContext(function($ctx1) {
  605. //>>excludeEnd("ctx");
  606. var $1;
  607. $1=self._new();
  608. $recv($1)._exception_(anException);
  609. $recv($1)._context_(aMethodContext);
  610. return $recv($1)._yourself();
  611. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  612. }, function($ctx1) {$ctx1.fill(self,"on:context:",{anException:anException,aMethodContext:aMethodContext},$globals.JavaScriptException.klass)});
  613. //>>excludeEnd("ctx");
  614. },
  615. //>>excludeStart("ide", pragmas.excludeIdeData);
  616. args: ["anException", "aMethodContext"],
  617. source: "on: anException context: aMethodContext\x0a\x09^ self new\x0a\x09\x09exception: anException;\x0a\x09\x09context: aMethodContext;\x0a\x09\x09yourself",
  618. referencedClasses: [],
  619. //>>excludeEnd("ide");
  620. messageSends: ["exception:", "new", "context:", "yourself"]
  621. }),
  622. $globals.JavaScriptException.klass);
  623. $core.addClass('MessageNotUnderstood', $globals.Error, ['message', 'receiver'], 'Kernel-Exceptions');
  624. //>>excludeStart("ide", pragmas.excludeIdeData);
  625. $globals.MessageNotUnderstood.comment="This exception is provided to support `Object>>doesNotUnderstand:`.";
  626. //>>excludeEnd("ide");
  627. $core.addMethod(
  628. $core.method({
  629. selector: "message",
  630. protocol: 'accessing',
  631. fn: function (){
  632. var self=this;
  633. return self["@message"];
  634. },
  635. //>>excludeStart("ide", pragmas.excludeIdeData);
  636. args: [],
  637. source: "message\x0a\x09^ message",
  638. referencedClasses: [],
  639. //>>excludeEnd("ide");
  640. messageSends: []
  641. }),
  642. $globals.MessageNotUnderstood);
  643. $core.addMethod(
  644. $core.method({
  645. selector: "message:",
  646. protocol: 'accessing',
  647. fn: function (aMessage){
  648. var self=this;
  649. self["@message"]=aMessage;
  650. return self;
  651. },
  652. //>>excludeStart("ide", pragmas.excludeIdeData);
  653. args: ["aMessage"],
  654. source: "message: aMessage\x0a\x09message := aMessage",
  655. referencedClasses: [],
  656. //>>excludeEnd("ide");
  657. messageSends: []
  658. }),
  659. $globals.MessageNotUnderstood);
  660. $core.addMethod(
  661. $core.method({
  662. selector: "messageText",
  663. protocol: 'accessing',
  664. fn: function (){
  665. var self=this;
  666. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  667. return $core.withContext(function($ctx1) {
  668. //>>excludeEnd("ctx");
  669. var $1;
  670. $1=$recv($recv($recv(self._receiver())._asString()).__comma(" does not understand #")).__comma($recv(self._message())._selector());
  671. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  672. $ctx1.sendIdx[","]=1;
  673. //>>excludeEnd("ctx");
  674. return $1;
  675. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  676. }, function($ctx1) {$ctx1.fill(self,"messageText",{},$globals.MessageNotUnderstood)});
  677. //>>excludeEnd("ctx");
  678. },
  679. //>>excludeStart("ide", pragmas.excludeIdeData);
  680. args: [],
  681. source: "messageText\x0a\x09^ self receiver asString, ' does not understand #', self message selector",
  682. referencedClasses: [],
  683. //>>excludeEnd("ide");
  684. messageSends: [",", "asString", "receiver", "selector", "message"]
  685. }),
  686. $globals.MessageNotUnderstood);
  687. $core.addMethod(
  688. $core.method({
  689. selector: "receiver",
  690. protocol: 'accessing',
  691. fn: function (){
  692. var self=this;
  693. return self["@receiver"];
  694. },
  695. //>>excludeStart("ide", pragmas.excludeIdeData);
  696. args: [],
  697. source: "receiver\x0a\x09^ receiver",
  698. referencedClasses: [],
  699. //>>excludeEnd("ide");
  700. messageSends: []
  701. }),
  702. $globals.MessageNotUnderstood);
  703. $core.addMethod(
  704. $core.method({
  705. selector: "receiver:",
  706. protocol: 'accessing',
  707. fn: function (anObject){
  708. var self=this;
  709. self["@receiver"]=anObject;
  710. return self;
  711. },
  712. //>>excludeStart("ide", pragmas.excludeIdeData);
  713. args: ["anObject"],
  714. source: "receiver: anObject\x0a\x09receiver := anObject",
  715. referencedClasses: [],
  716. //>>excludeEnd("ide");
  717. messageSends: []
  718. }),
  719. $globals.MessageNotUnderstood);
  720. $core.addClass('NonBooleanReceiver', $globals.Error, ['object'], 'Kernel-Exceptions');
  721. //>>excludeStart("ide", pragmas.excludeIdeData);
  722. $globals.NonBooleanReceiver.comment="NonBooleanReceiver exceptions may be thrown when executing inlined methods such as `#ifTrue:` with a non boolean receiver.";
  723. //>>excludeEnd("ide");
  724. $core.addMethod(
  725. $core.method({
  726. selector: "object",
  727. protocol: 'accessing',
  728. fn: function (){
  729. var self=this;
  730. return self["@object"];
  731. },
  732. //>>excludeStart("ide", pragmas.excludeIdeData);
  733. args: [],
  734. source: "object\x0a\x09^ object",
  735. referencedClasses: [],
  736. //>>excludeEnd("ide");
  737. messageSends: []
  738. }),
  739. $globals.NonBooleanReceiver);
  740. $core.addMethod(
  741. $core.method({
  742. selector: "object:",
  743. protocol: 'accessing',
  744. fn: function (anObject){
  745. var self=this;
  746. self["@object"]=anObject;
  747. return self;
  748. },
  749. //>>excludeStart("ide", pragmas.excludeIdeData);
  750. args: ["anObject"],
  751. source: "object: anObject\x0a\x09object := anObject",
  752. referencedClasses: [],
  753. //>>excludeEnd("ide");
  754. messageSends: []
  755. }),
  756. $globals.NonBooleanReceiver);
  757. });