₦airaland Forum

Welcome, Guest: RegisterLoginWith GoogleTrendingRecentNew

Stats: 3,331,196 members, 8,449,100 topics. Date: Tuesday, 21 July 2026 at 10:19 AM

Toggle theme

Why Is This Try Catch Not Working - Programming - Nairaland

Nairaland ForumScience/TechnologyProgrammingWhy Is This Try Catch Not Working (673 Views)

1 Reply (Go Down)

Why Is This Try Catch Not Working by chukwuebuka65(op): 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(f): 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(op): 10:42pm On Aug 20, 2023
Paystack:
It is working exactly as it should... you're sending a message but nowhere to receive it.
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(f): 10:48pm On Aug 20, 2023
chukwuebuka65:
Are you even a developer? What then is the purpose of a try catch block?
You asked it to console the error which it is clearly doing.

I'm not a developer wink


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(op): 10:49pm On Aug 20, 2023
Paystack:
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
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(op): 10:50pm On Aug 20, 2023
.
Re: Why Is This Try Catch Not Working by chukwuebuka65(op): 11:00pm On Aug 20, 2023
Paystack:
You asked it to console the error which it is clearly doing.

I'm not a developer wink


The block tried your faulty code it didn't work

It then catch it and spilled the trash out to u
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(op): 11:11pm On Aug 20, 2023
richebony:
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
This worked. But why ?
Re: Why Is This Try Catch Not Working by richebony: 12:23am On Aug 21, 2023
chukwuebuka65:
This worked. But why ?
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(f): 1:55am On Aug 21, 2023
richebony:
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
Nice
Re: Why Is This Try Catch Not Working by chukwuebuka65(op): 8:10am On Aug 21, 2023
richebony:
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
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(op): 9:19am On Aug 21, 2023
qtguru:
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
Alright boss.
1 Reply

Want To Learn Devops? The Free Resources Are Great, But Here's The Catch!Whatsapp's Struggles To Catch Up With Telegram And Outshine Them234

Can A 40 Years Old Man Still Acquire IT Skill?After Contract, WHAT NEXT?Cloud Solutions | Cloud Services – Storm Network.