44
55use Illuminate \Http \Request ;
66
7- use Dingo \Api \Exception \StoreResourceFailedException ;
7+ use Dingo \Api \Exception \ResourceException ;
88
99use Pterodactyl \Models ;
1010use Pterodactyl \Transformers \UserTransformer ;
1414use Pterodactyl \Exceptions \DisplayException ;
1515use Symfony \Component \HttpKernel \Exception \NotFoundHttpException ;
1616use Symfony \Component \HttpKernel \Exception \BadRequestHttpException ;
17+ use Symfony \Component \HttpKernel \Exception \ServiceUnavailableHttpException ;
1718
1819/**
1920 * @Resource("Users")
@@ -109,11 +110,11 @@ public function postUser(Request $request)
109110 'id ' => $ create
110111 ]));
111112 } catch (DisplayValidationException $ ex ) {
112- throw new StoreResourceFailedException ('A validation error occured. ' , json_decode ($ ex ->getMessage (), true ));
113+ throw new ResourceException ('A validation error occured. ' , json_decode ($ ex ->getMessage (), true ));
113114 } catch (DisplayException $ ex ) {
114- throw new StoreResourceFailedException ($ ex ->getMessage ());
115+ throw new ResourceException ($ ex ->getMessage ());
115116 } catch (\Exception $ ex ) {
116- throw new StoreResourceFailedException ('Unable to create a user on the system due to an error. ' );
117+ throw new ServiceUnavailableHttpException ('Unable to create a user on the system due to an error. ' );
117118 }
118119 }
119120
@@ -142,11 +143,11 @@ public function patchUser(Request $request, $id)
142143 $ user ->update ($ id , $ request ->all ());
143144 return Models \User::findOrFail ($ id );
144145 } catch (DisplayValidationException $ ex ) {
145- throw new StoreResourceFailedException ('A validation error occured. ' , json_decode ($ ex ->getMessage (), true ));
146+ throw new ResourceException ('A validation error occured. ' , json_decode ($ ex ->getMessage (), true ));
146147 } catch (DisplayException $ ex ) {
147- throw new StoreResourceFailedException ($ ex ->getMessage ());
148+ throw new ResourceException ($ ex ->getMessage ());
148149 } catch (\Exception $ ex ) {
149- throw new StoreResourceFailedException ('Unable to create a user on the system due to an error. ' );
150+ throw new ServiceUnavailableHttpException ('Unable to update a user on the system due to an error. ' );
150151 }
151152 }
152153
@@ -171,9 +172,9 @@ public function deleteUser(Request $request, $id)
171172 $ user ->delete ($ id );
172173 return $ this ->response ->noContent ();
173174 } catch (DisplayException $ ex ) {
174- throw new StoreResourceFailedException ($ ex ->getMessage ());
175+ throw new ResourceException ($ ex ->getMessage ());
175176 } catch (\Exception $ ex ) {
176- throw new StoreResourceFailedException ('Unable to delete this user due to an error. ' );
177+ throw new ServiceUnavailableHttpException ('Unable to delete this user due to an error. ' );
177178 }
178179 }
179180
0 commit comments