github.com/matrixorigin/matrixone@v1.2.0/pkg/common/moerr/error_handling.md (about) 1 # Error Handling 2 3 Rule is very simple, in the code, if an error can be handled 4 by caller, use comma ok. If the error cannot be handled and 5 will result in query abort, just panic. 6 7 You should not recover any panics unless it is at a few well 8 defined places. It really should be just one place, but 9 well, we have a few. 10 11 Our code should ALWAYS panic with a well defined moerr error. 12 This will make sure a meaningful error message pops up to user. 13 When generate an error, please look at the already defined 14 error code. If none fits, create your own error code. 15 It is arguably better to put error message format in the Error 16 class as well, maybe we will sometime later. 17 18 We should have prevented all runtime panics, but if it really 19 happens during runtime, we should convert the panic to an internal 20 error. *ANY internal error is a bug*. 21 22 There are also a few error code that are not considered error. 23 They are used to give user a meaningful info/warn message. An 24 example will be truncation for varchar(N) columns. NYI yet. 25