Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / NewStats: 3,161,539 members, 7,847,227 topics. Date: Saturday, 01 June 2024 at 01:15 PM |
Nairaland Forum / Science/Technology / Programming / Why Is This Try Catch Not Working (313 Views)
Whatsapp's Struggles To Catch Up With Telegram And Outshine Them (2) (3) (4)
Why Is This Try Catch Not Working by chukwuebuka65(m): 10:04pm On Aug 20, 2023 |
.
|
Re: Why Is This Try Catch Not Working by richebony: 10:34pm On Aug 20, 2023 |
I think set timeout() is asynchronous and registers an event that is handled by the libuv . Place another try-catch inside your setTimeout async block |
Re: Why Is This Try Catch Not Working by Paystack: 10:37pm On Aug 20, 2023 |
It is working exactly as it should... you're sending a message but nowhere to receive it. You need to add Onmessage listener in your contentScript, PopUp or the Background itself |
Re: Why Is This Try Catch Not Working by chukwuebuka65(m): 10:42pm On Aug 20, 2023 |
Paystack: Are you even a developer? What then is the purpose of a try catch block? |
Re: Why Is This Try Catch Not Working by Paystack: 10:48pm On Aug 20, 2023 |
chukwuebuka65: You asked it to console the error which it is clearly doing. I'm not a developer The block tried your faulty code it didn't work It then catch it and spilled the trash out to u |
Re: Why Is This Try Catch Not Working by chukwuebuka65(m): 10:49pm On Aug 20, 2023 |
Paystack: That’s not the issue. I know why the error is happening . My question is why the catch block is not catching the error and logging it to the console. |
Re: Why Is This Try Catch Not Working by chukwuebuka65(m): 10:50pm On Aug 20, 2023 |
. |
Re: Why Is This Try Catch Not Working by chukwuebuka65(m): 11:00pm On Aug 20, 2023 |
Paystack: The second pics is not the console, it’s the extension management tab. The console is empty |
Re: Why Is This Try Catch Not Working by chukwuebuka65(m): 11:11pm On Aug 20, 2023 |
richebony: This worked. But why ? |
Re: Why Is This Try Catch Not Working by richebony: 12:23am On Aug 21, 2023 |
chukwuebuka65: I think I explained in the preceding text, the setTimeout function is asynchronous and isn't a native js function, and your callback function is invoked on a different execution context because its the libuv [c++] APIs that nodejs delegates the timer function to. So your try-catch block isn't bound to your callback function because it exists in a different execution context |
Re: Why Is This Try Catch Not Working by Paystack: 1:55am On Aug 21, 2023 |
richebony: Nice |
Re: Why Is This Try Catch Not Working by chukwuebuka65(m): 8:10am On Aug 21, 2023 |
richebony: Ok makes sense. Thanks |
Re: Why Is This Try Catch Not Working by qtguru(m): 8:46am On Aug 21, 2023 |
rich-ebony is correct in a way, but also you're sending a post-message, the source isn't sure whether to close it or not, because it is not informed of what to do, from the onMessage handler you send a sendResponse back so that it will close. That is the Chrome extension architecture around post-messaging. try it, i faced alot of that too |
Re: Why Is This Try Catch Not Working by chukwuebuka65(m): 9:19am On Aug 21, 2023 |
qtguru: Alright boss. |
(1) (Reply)
Mentor Needed / Urgent Help Needed, Please See Attached Pics / Please I Need Someone Who Can Teach Me Video Editing In Calabar Or Akwa Ibom
(Go Up)
Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health religion celebs tv-movies music-radio literature webmasters programming techmarket Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10) Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 19 |