Could you tell me how to deal with the front-end "error"?

the questions you want to ask are as follows:

  1. when does the front end need to use the try {} catch {} statement, which is rarely seen in the front end, what scenarios will be used?
  2. as we all know, there are many "exceptions" at the front end. For example, network requests may be interrupted due to poor network status. If you see some items are called back, they will prompt the user with a pop-up window, and sometimes they will directly console.log () print errors.
    2.1What kind of error is suitable for pop-up prompts and which kind of error is suitable for printing errors?
    2.2 some background errors should not be shown directly to the user, right? (for example, database errors, will it give others a chance if you expose too much information), how to deal with such sensitive errors?

I do not know how you designed this error handling method, please do not hesitate to comment, thank you very much.

Mar.25,2021

1. My understanding is that try {} catch {} is used in
2. When an exception may occur, but I hope that the exception will not affect the subsequent code execution. When calling the pop-up window, you need to inform the user of this exception and use it only when you need to do some handling. In other cases, you usually use console.log () print error
3 for debugging convenience. Normally, the error thrown by the foreground does not need to contain specific information, but only needs to tell the user what exception has occurred and what actions the user may need to do to deal with the exception
4. If the exception thrown by the front end is detailed enough, it is true that there will be security problems


JSON.parse, JSON.stringify, httpRequest and other unpredictable scenarios, I will use try {} catch {}

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1bede67-31bbd.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1bede67-31bbd.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?