File tree Expand file tree Collapse file tree 1 file changed +13
-1
lines changed
app/code/Magento/Webapi/Controller/Rest Expand file tree Collapse file tree 1 file changed +13
-1
lines changed Original file line number Diff line number Diff line change 13
13
use Magento \Framework \App \DeploymentConfig ;
14
14
use Magento \Framework \ObjectManagerInterface ;
15
15
use Magento \Framework \Config \ConfigOptionsListConstants ;
16
+ use Magento \Framework \Phrase ;
17
+ use Magento \Framework \Webapi \Exception as WebapiException ;
16
18
17
19
/**
18
20
* REST request processor for synchronous requests
@@ -92,7 +94,17 @@ public function process(\Magento\Framework\Webapi\Rest\Request $request)
92
94
/**
93
95
* @var \Magento\Framework\Api\AbstractExtensibleObject $outputData
94
96
*/
95
- $ outputData = call_user_func_array ([$ service , $ serviceMethodName ], $ inputParams );
97
+ try {
98
+ $ outputData = call_user_func_array ([$ service , $ serviceMethodName ], $ inputParams );
99
+ } catch (\Exception $ e ) {
100
+ // Re-throw other exceptions as WebapiException with 400 status code
101
+ throw new WebapiException (
102
+ new Phrase ($ e ->getMessage ()),
103
+ 0 ,
104
+ WebapiException::HTTP_BAD_REQUEST
105
+ );
106
+ }
107
+
96
108
$ outputData = $ this ->serviceOutputProcessor ->process (
97
109
$ outputData ,
98
110
$ serviceClassName ,
You can’t perform that action at this time.
0 commit comments