Kernel-Exceptions.js 24 KB

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