PHP try will also throw an exception if it is executed successfully
try{
Do something.
Db::commit();
return "success":
}cathe(\Exception $exception){
Db::rollback();
return "error":
}
Many of the returned results you get directly here, no matter whether your operation is successful or not, are returned as exceptions and go into error
Print exception error:
var_dump($e->getMessage());
The result is
""
There is no information
at this time, it should be noted that the return in the exception try will be thrown as an exception. There are two solutions.
First:
will
catch (\Exception $exception)
Change to (eg: use tp6, please rewrite the specific path within the framework)
catch (\think\Exception\DbException $exception)
Second:
save the information that needs to return in the variable, and finally output:
$_retData = [];
try{
Do something.
Db::commit();
$_retData['data'] = [];
$_retData['messages'] = "success";
}cathe(\Exception $exception){
Db::rollback();
return "error":
}
return $_retData;
Read More:
- After matlab2018a is successfully installed, a licensing error appears when it is opened: – 8523
- When a system is deployed on weblogic12.2.1.3, it reports an error “IllegalStateException zip file closed”. When it is deployed on weblogic12.2.1.2, it does not report an error and can be accessed normally.
- After windows VM is installed successfully, it is always prompted that this application may not work properly
- Python module learning-Paramiko-Use python to throw an exception: Authentication failed.
- Zeppelin starts successfully, but an error is reported
- Zeppelin starts successfully, but an error is reported
- After upgrading php7, PHP program prompts an error: operator not supported for strings in causes and Solutions
- When the mybatis field contains an expression, an error is reported when it is stored in the database
- Ant Design ‘cross env’ is not an internal or external command, nor is it an error reporting problem for a runnable program
- [OpenGL · error] visual studio 2019 reports an error. It is an external symbol gladloadglloader that cannot be parsed. This symbol is referenced in the function main
- There is an unhandled exception at: 0xc0000005: an access conflict occurred while reading location 0x00000000.
- The Vue project is packaged and deployed to tomcat, and an Error 404 is reported as soon as it is refreshed
- Exception record. When eclipse starts, an error is reported when workspace is opened
- Error code elifecycle errorno when NPM install command is executed in Vue project
- After node.js is installed, use the instruction node version in vscode to show that it is not an external or internal instruction. The solution is as follows:
- “ XX.app ”It is damaged and cannot be opened. You should move it to the wastebasket.
- Vue introduction path is correct, but it always reports an error: already included file name‘ ××ב differs from file name ‘ ××ב only in casing.
- When the MAC M1 uiautomatorviewer is opened, it displays blank or reports an error
- It is an error to use a section registered as allowDefinition=’MachineToApplication’ beyond applicat
- It is invalid to submit the content directly after pasting it on the mobile terminal of Vue HTML5 editor