fix(api): handle JSON response in service creation and update methods for improved error handling
This commit is contained in:
@@ -380,6 +380,9 @@ class ServicesController extends Controller
|
|||||||
|
|
||||||
$service = new Service;
|
$service = new Service;
|
||||||
$result = $this->upsert_service($request, $service, $teamId);
|
$result = $this->upsert_service($request, $service, $teamId);
|
||||||
|
if ($result instanceof \Illuminate\Http\JsonResponse) {
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
|
||||||
return response()->json(serializeApiResponse($result))->setStatusCode(201);
|
return response()->json(serializeApiResponse($result))->setStatusCode(201);
|
||||||
} else {
|
} else {
|
||||||
@@ -608,12 +611,14 @@ class ServicesController extends Controller
|
|||||||
}
|
}
|
||||||
|
|
||||||
$service = Service::whereRelation('environment.project.team', 'id', $teamId)->whereUuid($request->uuid)->first();
|
$service = Service::whereRelation('environment.project.team', 'id', $teamId)->whereUuid($request->uuid)->first();
|
||||||
|
|
||||||
if (! $service) {
|
if (! $service) {
|
||||||
return response()->json(['message' => 'Service not found.'], 404);
|
return response()->json(['message' => 'Service not found.'], 404);
|
||||||
}
|
}
|
||||||
|
|
||||||
$result = $this->upsert_service($request, $service, $teamId);
|
$result = $this->upsert_service($request, $service, $teamId);
|
||||||
|
if ($result instanceof \Illuminate\Http\JsonResponse) {
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
|
||||||
return response()->json(serializeApiResponse($result))->setStatusCode(200);
|
return response()->json(serializeApiResponse($result))->setStatusCode(200);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user