Essay sample library > Catch Exception high in the call stack- when dealing with n tiers?

Catch Exception high in the call stack- when dealing with n tiers?

2023-02-26 14:48:46

Rule 1 Capture only exceptions to be handled. Depending on the handle, I mean that the request to process the client can continue. You may capture a length long enough to log information (do not abuse it, normal stack is sufficient information), another propagation-friendly (based on runtime) Convert to error. Even if you can not handle it, do not bother to catch it. This is just additional code and is useless. Even if you record or convert, it will eventually be re-thrown

In most cases, exceptions can not be handled. really. Many people do not understand this. However, in reality, if you read or write a disk IOException, the game will end. Could not complete request for user. If the network is unstable, it can not communicate with the database. The same can be said.

The only thing you can do when raising an exception that Rule 2 can not be processed is to fail in a way that is useful to the user. This means that it will be logged for later analysis (including original stack / cause) and then report the user as useful as possible. Clean up everything you need to keep the system in a consistent state

Since communication with this end user is done at a very high level, this usually means that you need to acquire that level. In most cases, we know that exception handling from the first time to the highest level has little meaning, we can record it and capture it to report it to the user. I often convert it to the form of RuntimeException, but this is simply to simplify the propagation in the layer.

The most important and important thing is to understand that you can not usually handle exceptions. As such, the code you write for them should be as simple as possible.

Error handling in Rust is meant to be done by returning a value called "Result" which can indicate success or failure. Unlike exceptions, stack trace is not captured even if Rust creates an error value, so the acquired stack trace belongs to the code that reported the error, not the code that caused the error. Because Figma's document format is compressed, our server needs to be able to handle compressed data. We attempted to use two separate Rust compression libraries. All of them were used by Mozilla's next-generation browser prototype Servo, but both had subtle precision problems causing data loss.

Rule 1 Capture only exceptions to be handled. Depending on the handle, I mean that the request to process the client can continue. You may capture a length long enough to log information (do not abuse it, normal stack is sufficient information), another propagation-friendly (based on runtime) Convert to error. Even if you can not handle it, do not bother to catch it. This is just additional code and is useless. Even if you record or convert, it will eventually be rethrown. In most cases, exceptions can not be handled. really. Many people do not understand this. However, in reality, if you read or write a disk IOException, the game will end. Could not complete request for user. If the network is unstable, it can not communicate with the database. The same can be said.

Ranking and calibration are different. The concept of "stack level" is often said, and it is often used as a slogan for the process of assigning a "one to one" score for each member of the group. This is always a bad process. The accuracy implied by such a system is not merely available. What if someone tries to explain the difference between No. 63 and No. 64 with a team of 100 people? As mentioned earlier, proofreading practice is one of the relative performance among peer group members. The size and number of these groups are fixed, and once a sufficient population size is completed, unlimited debate on border cases can almost certainly be avoided. Best Practice: Definition of a performance group that team members fail but do not rank finer or get "closer" to other groups