@@ -15,9 +15,15 @@ trait WooCommerceTrait
1515 */
1616 public function all ($ endpoint = '' , $ options = [])
1717 {
18- self ::__construct ();
18+ try {
19+ self ::__construct ();
1920
20- return $ this ->client ->get ($ endpoint , $ options );
21+ return $ this ->client ->get ($ endpoint , $ options );
22+
23+ } catch ( \Exception $ e ) {
24+ throw new \Exception ($ e ->getMessages (), 1 );
25+
26+ }
2127 }
2228
2329 /**
@@ -31,9 +37,15 @@ public function all($endpoint = '', $options = [])
3137 */
3238 public function find ($ endpoint = '' , $ options = [])
3339 {
34- self ::__construct ();
40+ try {
41+ self ::__construct ();
42+
43+ return $ this ->client ->get ($ endpoint , $ options );
3544
36- return $ this ->client ->get ($ endpoint , $ options );
45+ } catch ( \Exception $ e ) {
46+ throw new \Exception ($ e ->getMessages (), 1 );
47+
48+ }
3749 }
3850
3951 /**
@@ -47,9 +59,15 @@ public function find($endpoint = '', $options = [])
4759 */
4860 public function create ($ endpoint , $ data )
4961 {
50- self ::__construct ();
62+ try {
63+ self ::__construct ();
5164
52- return $ this ->client ->post ($ endpoint , $ data );
65+ return $ this ->client ->post ($ endpoint , $ data );
66+
67+ } catch ( \Exception $ e ) {
68+ throw new \Exception ($ e ->getMessages (), 1 );
69+
70+ }
5371 }
5472
5573 /**
@@ -63,9 +81,15 @@ public function create($endpoint, $data)
6381 */
6482 public function update ($ endpoint , $ data )
6583 {
66- self ::__construct ();
84+ try {
85+ self ::__construct ();
86+
87+ return $ this ->client ->put ($ endpoint , $ data );
6788
68- return $ this ->client ->put ($ endpoint , $ data );
89+ } catch ( \Exception $ e ) {
90+ throw new \Exception ($ e ->getMessages (), 1 );
91+
92+ }
6993 }
7094
7195 /**
@@ -79,9 +103,15 @@ public function update($endpoint, $data)
79103 */
80104 public function delete ($ endpoint , $ options = [])
81105 {
82- self ::__construct ();
106+ try {
107+ self ::__construct ();
83108
84- return $ this ->client ->delete ($ endpoint , $ options );
109+ return $ this ->client ->delete ($ endpoint , $ options );
110+
111+ } catch ( \Exception $ e ) {
112+ throw new \Exception ($ e ->getMessages (), 1 );
113+
114+ }
85115 }
86116
87117 /**
@@ -91,7 +121,15 @@ public function delete($endpoint, $options = [])
91121 */
92122 public function getRequest ()
93123 {
94- return $ this ->client ->http ->getRequest ();
124+ try {
125+
126+ return $ this ->client ->http ->getRequest ();
127+
128+ } catch ( \Exception $ e ) {
129+ throw new \Exception ($ e ->getMessages (), 1 );
130+
131+ }
132+
95133 }
96134
97135 /**
@@ -101,7 +139,14 @@ public function getRequest()
101139 */
102140 public function getResponse ()
103141 {
104- return $ this ->client ->http ->getResponse ();
142+ try {
143+
144+ return $ this ->client ->http ->getResponse ();
145+
146+ } catch ( \Exception $ e ) {
147+ throw new \Exception ($ e ->getMessages (), 1 );
148+
149+ }
105150 }
106151
107152 /**
0 commit comments