The invocation of internal API, the way that all kinds of case have thrown exceptions, or the way of returning values.

Internal API calls, ways in which all kinds of case have thrown exceptions, or ways in which values are returned

when the company calls the external interface, it will throw the wrong case abnormal way for the upper service,catch to deal with accordingly. For example:

Result result = service.invoke();
if(result= 1){
    thow ServiceException();//
}

A large number of code styles are like this, but if the wrong case has been thrown to the upper layer in an abnormal way, if the upper layer needs some information about the returned result at that time to handle the exception, the upper layer can only put the returned result object in the exception, and the upper layer can only catch the exception. It is strange to get the return result from the exception and deal with it. How do we handle it or how do we treat it in this way

Sep.03,2021

throwing an exception is more intuitive, and the way to return a value requires upper-level developers to understand that the value belongs to exception data


exception is more convenient to handle uniformly, otherwise it is necessary to judge whether an error is returned or not.

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-1b3e74c-2b159.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-1b3e74c-2b159.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?