JavaScript try catch

Asked 2 years ago, Updated 2 years ago, 20 views

I don't know where the error is in Javascript, so I would like to implement try catch.

I would appreciate it if you could tell me a simple try catch.
Thank you for your cooperation.

javascript

2022-09-30 10:48

1 Answers

First of all, let's take a look at

try{
    /* Here's the whole code*/
} catch(e){
    console.error(e);
}

I think it would be good toThis means catching the first error in the entire code and outputting it directly to the console.

Also, if you just want to locate the error and you're running it on your browser, you should use the browser tool (e.g., Google Chrome's "Developer Tool" Console) to find out what the error is and how many files and lines it is.

--From Comment by rio.irikami.


2022-09-30 10:48

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.