Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #22408 > unrolled thread
| Started by | MC <news@aisus.com> |
|---|---|
| First post | 2013-12-25 20:48 -0600 |
| Last post | 2014-01-13 04:37 -0800 |
| Articles | 20 on this page of 21 — 7 participants |
Back to article view | Back to comp.lang.javascript
Insert Function into Error Object MC <news@aisus.com> - 2013-12-25 20:48 -0600
Re: Insert Function into Error Object Joao Rodrigues <groups_jr-1@yahoo.com.br> - 2013-12-26 18:46 -0200
Re: Insert Function into Error Object MC <news@aisus.com> - 2013-12-26 18:47 -0600
Re: Insert Function into Error Object "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2013-12-27 09:54 +0100
Re: Insert Function into Error Object MC <news@aisus.com> - 2013-12-27 10:16 -0600
Re: Insert Function into Error Object MC <news@aisus.com> - 2013-12-27 10:26 -0600
Re: Insert Function into Error Object JJ <duh@nah.meh> - 2013-12-28 00:53 +0700
Re: Insert Function into Error Object "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2013-12-26 20:17 -0800
Re: Insert Function into Error Object Joao Rodrigues <groups_jr-1@yahoo.com.br> - 2013-12-27 11:15 -0200
Re: Insert Function into Error Object MC <news@aisus.com> - 2013-12-27 10:09 -0600
Re: Insert Function into Error Object Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2013-12-27 17:24 +0100
Re: Insert Function into Error Object MC <news@aisus.com> - 2013-12-27 10:34 -0600
Re: Insert Function into Error Object "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2013-12-27 17:57 +0100
Re: Insert Function into Error Object MC <news@aisus.com> - 2013-12-28 10:20 -0600
Re: Insert Function into Error Object JJ <duh@nah.meh> - 2013-12-29 07:12 +0700
Re: Insert Function into Error Object Cezary Tomczyk <cezary.tomczyk@gmail.com> - 2013-12-29 20:13 +0100
Re: Insert Function into Error Object Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2013-12-29 20:31 +0100
Re: Insert Function into Error Object MC <news@aisus.com> - 2014-01-12 11:26 -0600
Re: Insert Function into Error Object "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2014-01-13 02:59 -0800
Re: Insert Function into Error Object Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2014-01-13 12:59 +0100
Re: Insert Function into Error Object "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2014-01-13 04:37 -0800
Page 1 of 2 [1] 2 Next page →
| From | MC <news@aisus.com> |
|---|---|
| Date | 2013-12-25 20:48 -0600 |
| Subject | Insert Function into Error Object |
| Message-ID | <e799$52bb95fb$adbbaaad$21889@ALLTEL.NET> |
FYI, I have researched, tried, and failed.
I am trying to extend the Error object in such fashion that upon being
created by a js error, my function is called. I already know I can do
window.onError(), but I need to insert my own function into the Error
object if that is possible.
function myErrorCall(e) {
// do something
}
Also, I do not want to extend the Error object and throw myError objects.
Thank you!
[toc] | [next] | [standalone]
| From | Joao Rodrigues <groups_jr-1@yahoo.com.br> |
|---|---|
| Date | 2013-12-26 18:46 -0200 |
| Message-ID | <l9i4id$5ka$1@speranza.aioe.org> |
| In reply to | #22408 |
Em 26/12/2013 00:48, MC escreveu:
>
>
> FYI, I have researched, tried, and failed.
> I am trying to extend the Error object in such fashion that upon being
> created by a js error, my function is called. I already know I can do
> window.onError(), but I need to insert my own function into the Error
> object if that is possible.
>
> function myErrorCall(e) {
> // do something
> }
>
> Also, I do not want to extend the Error object and throw myError objects.
>
A hint from "The Definitive Guide", 4th Edition:
<http://docstore.mik.ua/orelly/webprog/jscript/ch13_05.htm>
--
Joao Rodrigues (J.R.)
[toc] | [prev] | [next] | [standalone]
| From | MC <news@aisus.com> |
|---|---|
| Date | 2013-12-26 18:47 -0600 |
| Message-ID | <8406d$52bccdf8$adbbaaad$15744@ALLTEL.NET> |
| In reply to | #22416 |
That refers to the onError method, which I already know about and does not modify the Error object. Thank you for posting!
[toc] | [prev] | [next] | [standalone]
| From | "Evertjan." <exxjxw.hannivoort@inter.nl.net> |
|---|---|
| Date | 2013-12-27 09:54 +0100 |
| Message-ID | <XnsA2A364D98BB60eejj99@194.109.133.133> |
| In reply to | #22418 |
MC <news@aisus.com> wrote on 27 dec 2013 in comp.lang.javascript: > That refers to the onError method, which I already know about and does > not modify the Error object. What is "that"? This is Usenet, not an email, so please quote what you are responding on. -- Evertjan. The Netherlands. (Please change the x'es to dots in my emailaddress)
[toc] | [prev] | [next] | [standalone]
| From | MC <news@aisus.com> |
|---|---|
| Date | 2013-12-27 10:16 -0600 |
| Message-ID | <52BDA7FA.7020509@aisus.com> |
| In reply to | #22421 |
On 12/27/2013 2:54 AM, Evertjan. wrote: > MC <news@aisus.com> wrote on 27 dec 2013 in comp.lang.javascript: > >> That refers to the onError method, which I already know about and does >> not modify the Error object. > > What is "that"? > > This is Usenet, not an email, so please quote what you are responding on. > Evertjan...cranky...Happy Holidays!!!! :-) So I did...better ;-) Do you have any input? I need to insert a function to be called inside the Error object, as part of the Error process. Where is David Mark and our other illustrious group members? David and you were always particularily insightful.
[toc] | [prev] | [next] | [standalone]
| From | MC <news@aisus.com> |
|---|---|
| Date | 2013-12-27 10:26 -0600 |
| Message-ID | <52BDAA2B.6040301@aisus.com> |
| In reply to | #22421 |
On 12/27/2013 2:54 AM, Evertjan. wrote: > MC <news@aisus.com> wrote on 27 dec 2013 in comp.lang.javascript: > >> That refers to the onError method, which I already know about and does >> not modify the Error object. > > What is "that"? > > This is Usenet, not an email, so please quote what you are responding on. > Evertjan...cranky...Happy Holidays!!!! :-) So I did include what I was responding to...better ;-) Do you have any input? I need to insert a function to be called inside the Error object, as part of the Error process. Where is David Mark and our other illustrious group members? David and you were always particularily insightful.
[toc] | [prev] | [next] | [standalone]
| From | JJ <duh@nah.meh> |
|---|---|
| Date | 2013-12-28 00:53 +0700 |
| Message-ID | <9yyo6ojgrhhw$.l8b33ot6rcbo.dlg@40tude.net> |
| In reply to | #22418 |
On Thu, 26 Dec 2013 18:47:07 -0600, MC wrote:
> That refers to the onError method, which I already know about and does
> not modify the Error object.
>
> Thank you for posting!
What you want shouldn't be allowed. It can crash the interpreter.
You can replace the Error object constructor, but the interpreter use its
own reference to the original Error object constructor when generating an
exception.
If the Error object is allowed to be replaced, then code like this would be
catastrophic.
function myError(){
var a = undefinedVariable;
a = a.value; //BAM! Infinite loop.
}
window.Error = myError;
var a = undefinedVariable;
a = a.value; //BAM!
[toc] | [prev] | [next] | [standalone]
| From | "Michael Haufe (TNO)" <tno@thenewobjective.com> |
|---|---|
| Date | 2013-12-26 20:17 -0800 |
| Message-ID | <9dcb900f-eeca-432e-9410-10843e8d3f00@googlegroups.com> |
| In reply to | #22408 |
On Wednesday, December 25, 2013 8:48:48 PM UTC-6, MC wrote: > Also, I do not want to extend the Error object and throw myError objects. Why not? Another alternative is to shadow the Error object. Depending on the target platform, you could use a proxy as well: <https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy>
[toc] | [prev] | [next] | [standalone]
| From | Joao Rodrigues <groups_jr-1@yahoo.com.br> |
|---|---|
| Date | 2013-12-27 11:15 -0200 |
| Message-ID | <l9jugt$r2g$1@speranza.aioe.org> |
| In reply to | #22422 |
On Fri 27/12/2013 02:17, Michael Haufe (TNO) wrote: > On Wednesday, December 25, 2013 8:48:48 PM UTC-6, MC wrote: > >> Also, I do not want to extend the Error object and throw myError objects. > > Why not? Yes, it is possible to extend the Error.prototype, by adding the OP's function as a method: <https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/prototype> -- Joao Rodrigues (J.R.)
[toc] | [prev] | [next] | [standalone]
| From | MC <news@aisus.com> |
|---|---|
| Date | 2013-12-27 10:09 -0600 |
| Message-ID | <a1049$52bda62e$adbbaaad$27770@ALLTEL.NET> |
| In reply to | #22423 |
On 12/27/2013 7:15 AM, Joao Rodrigues wrote: > On Fri 27/12/2013 02:17, Michael Haufe (TNO) wrote: >> On Wednesday, December 25, 2013 8:48:48 PM UTC-6, MC wrote: >> >>> Also, I do not want to extend the Error object and throw myError >>> objects. >> >> Why not? > > Yes, it is possible to extend the Error.prototype, by adding the OP's > function as a method: > <https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/prototype> > > > Because it is not in the project spec. I am not allowed to create a new extended myError object. I need to add the functionality to the Error object.
[toc] | [prev] | [next] | [standalone]
| From | Thomas 'PointedEars' Lahn <PointedEars@web.de> |
|---|---|
| Date | 2013-12-27 17:24 +0100 |
| Message-ID | <2142308.9f43sPy3Wm@PointedEars.de> |
| In reply to | #22422 |
Michael Haufe (TNO) wrote: > On Wednesday, December 25, 2013 8:48:48 PM UTC-6, MC wrote: >> Also, I do not want to extend the Error object and throw myError objects. > > Why not? Depends on what is meant by that. Inheriting from Error.prototype and calling Error from a user-defined constructor at least works well in JSX: <http://PointedEars.de/wsvn/JSX/trunk/object.js> > Another alternative is to shadow the Error object. Meaning? -- PointedEars Twitter: @PointedEars2 Please do not Cc: me. / Bitte keine Kopien per E-Mail.
[toc] | [prev] | [next] | [standalone]
| From | MC <news@aisus.com> |
|---|---|
| Date | 2013-12-27 10:34 -0600 |
| Message-ID | <52BDABFF.7080501@aisus.com> |
| In reply to | #22432 |
On 12/27/2013 10:24 AM, Thomas 'PointedEars' Lahn wrote: > Michael Haufe (TNO) wrote: > >> On Wednesday, December 25, 2013 8:48:48 PM UTC-6, MC wrote: >>> Also, I do not want to extend the Error object and throw myError objects. >> >> Why not? > > Depends on what is meant by that. Inheriting from Error.prototype and > calling Error from a user-defined constructor at least works well in JSX: > > <http://PointedEars.de/wsvn/JSX/trunk/object.js> > >> Another alternative is to shadow the Error object. > > Meaning? > > I second that...what is shadowing the Error object?
[toc] | [prev] | [next] | [standalone]
| From | "Evertjan." <exxjxw.hannivoort@inter.nl.net> |
|---|---|
| Date | 2013-12-27 17:57 +0100 |
| Message-ID | <XnsA2A3B6C09A0CCeejj99@194.109.133.133> |
| In reply to | #22434 |
MC <news@aisus.com> wrote on 27 dec 2013 in comp.lang.javascript: > On 12/27/2013 10:24 AM, Thomas 'PointedEars' Lahn wrote: >> Michael Haufe (TNO) wrote: >> >>> On Wednesday, December 25, 2013 8:48:48 PM UTC-6, MC wrote: >>>> Also, I do not want to extend the Error object and throw myError >>>> objects. >>> >>> Why not? >> >> Depends on what is meant by that. Inheriting from Error.prototype and >> calling Error from a user-defined constructor at least works well in >> JSX: >> >> <http://PointedEars.de/wsvn/JSX/trunk/object.js> >> >>> Another alternative is to shadow the Error object. >> >> Meaning? > I second that...what is shadowing the Error object? Stealthily following such object by private eyes? -- Evertjan. The Netherlands. (Please change the x'es to dots in my emailaddress)
[toc] | [prev] | [next] | [standalone]
| From | MC <news@aisus.com> |
|---|---|
| Date | 2013-12-28 10:20 -0600 |
| Message-ID | <d539b$52befa47$adb8eda9$1902@ALLTEL.NET> |
| In reply to | #22408 |
On 12/25/2013 8:48 PM, MC wrote:
>
>
> FYI, I have researched, tried, and failed.
> I am trying to extend the Error object in such fashion that upon being
> created by a js error, my function is called. I already know I can do
> window.onError(), but I need to insert my own function into the Error
> object if that is possible.
>
> function myErrorCall(e) {
> // do something
> }
>
> Also, I do not want to extend the Error object and throw myError objects.
>
> Thank you!
So no one has any ideas on how to attach a function to be called when
the Error object is called?
[toc] | [prev] | [next] | [standalone]
| From | JJ <duh@nah.meh> |
|---|---|
| Date | 2013-12-29 07:12 +0700 |
| Message-ID | <1cxxb05map0dv.4m5hnl9bzy1o.dlg@40tude.net> |
| In reply to | #22449 |
On Sat, 28 Dec 2013 10:20:48 -0600, MC wrote:
> On 12/25/2013 8:48 PM, MC wrote:
>>
>>
>> FYI, I have researched, tried, and failed.
>> I am trying to extend the Error object in such fashion that upon being
>> created by a js error, my function is called. I already know I can do
>> window.onError(), but I need to insert my own function into the Error
>> object if that is possible.
>>
>> function myErrorCall(e) {
>> // do something
>> }
>>
>> Also, I do not want to extend the Error object and throw myError objects.
>>
>> Thank you!
>
> So no one has any ideas on how to attach a function to be called when
> the Error object is called?
It shouldn't be allowed. It can cause infinite exception and stack overflow
if the Error constructor causes an exception.
[toc] | [prev] | [next] | [standalone]
| From | Cezary Tomczyk <cezary.tomczyk@gmail.com> |
|---|---|
| Date | 2013-12-29 20:13 +0100 |
| Message-ID | <l9ps7t$doa$1@dont-email.me> |
| In reply to | #22449 |
2013-12-28 17:20, MC wrote: [...] > So no one has any ideas on how to attach a function to be called when > the Error object is called? > Take a look at: http://stackoverflow.com/questions/783818/how-do-i-create-a-custom-error-in-javascript -- Cezary Tomczyk http://www.ctomczyk.pl/
[toc] | [prev] | [next] | [standalone]
| From | Thomas 'PointedEars' Lahn <PointedEars@web.de> |
|---|---|
| Date | 2013-12-29 20:31 +0100 |
| Message-ID | <2810704.ZYsuzNNPX5@PointedEars.de> |
| In reply to | #22478 |
Cezary Tomczyk wrote:
> 2013-12-28 17:20, MC wrote:
> [...]
>> So no one has any ideas on how to attach a function to be called when
>> the Error object is called?
>
> Take a look at:
> http://stackoverflow.com/questions/783818/how-do-i-create-a-custom-error-in-javascript
The accepted answer is wrong as explained many times, not least in
<http://stackoverflow.com/a/12593269/855543>
The correct approach is
NotImplementedError.prototype = (function () {
function Foo () {}
Foo.prototype = Error.prototype;
return new Foo;
}());
or simply
NotImplementedError.prototype = Object.create(Error.prototype, {
…
});
See also JSX:object.js.
--
PointedEars
Twitter: @PointedEars2
Please do not Cc: me. / Bitte keine Kopien per E-Mail.
[toc] | [prev] | [next] | [standalone]
| From | MC <news@aisus.com> |
|---|---|
| Date | 2014-01-12 11:26 -0600 |
| Message-ID | <b3a7b$52d2d03c$6216dabd$7343@ALLTEL.NET> |
| In reply to | #22408 |
On 12/25/2013 8:48 PM, MC wrote:
>
>
> FYI, I have researched, tried, and failed.
> I am trying to extend the Error object in such fashion that upon being
> created by a js error, my function is called. I already know I can do
> window.onError(), but I need to insert my own function into the Error
> object if that is possible.
>
> function myErrorCall(e) {
> // do something
> }
>
> Also, I do not want to extend the Error object and throw myError objects.
>
> Thank you!
I guess no one knows how to insert a function into the Error object or
add an event listener to it. All the suggestions have been to do
something else.
[toc] | [prev] | [next] | [standalone]
| From | "Michael Haufe (TNO)" <tno@thenewobjective.com> |
|---|---|
| Date | 2014-01-13 02:59 -0800 |
| Message-ID | <d73c9697-ad19-4d88-a299-610be3765e0d@googlegroups.com> |
| In reply to | #22583 |
On Sunday, January 12, 2014 11:26:58 AM UTC-6, MC wrote: > I guess no one knows how to insert a function into the Error object or > add an event listener to it. All the suggestions have been to do > something else. Use a proxy
[toc] | [prev] | [next] | [standalone]
| From | Thomas 'PointedEars' Lahn <PointedEars@web.de> |
|---|---|
| Date | 2014-01-13 12:59 +0100 |
| Message-ID | <4172345.PDqZUlTlOc@PointedEars.de> |
| In reply to | #22593 |
Michael Haufe (TNO) wrote: > On Sunday, January 12, 2014 11:26:58 AM UTC-6, MC wrote: >> I guess no one knows how to insert a function into the Error object or >> add an event listener to it. All the suggestions have been to do >> something else. > > Use a proxy How would this “insert a function into the Error object” or “add an event listener to the Error object”? ISTM the OP either does not know what an event listener is, or that events have to do with the DOM, not the core language. Indeed, they are not clear at all on what they intend to do and why they think it is necessary in the first place. This is not a guessing game. -- PointedEars Twitter: @PointedEars2 Please do not Cc: me. / Bitte keine Kopien per E-Mail.
[toc] | [prev] | [next] | [standalone]
Page 1 of 2 [1] 2 Next page →
Back to top | Article view | comp.lang.javascript
csiph-web