Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[stable4.5] fix: dont forward internal exceptions #5554

Merged
merged 1 commit into from
Nov 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions lib/Controller/AppointmentConfigController.php
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ public function create(
return JsonResponse::success($appointmentConfig);
} catch (ServiceException $e) {
$this->logger->error('Could not create new configuration', ['exception' => $e]);
return JsonResponse::errorFromThrowable($e);
return JsonResponse::fail($e->getMessage(), Http::STATUS_INTERNAL_SERVER_ERROR);
}
}

Expand Down Expand Up @@ -257,7 +257,7 @@ public function update(
$appointmentConfig = $this->appointmentConfigService->findByIdAndUser($id, $this->userId);
} catch (ClientException $e) {
$this->logger->error('Could not find configuration with id ' . $id, ['exception' => $e]);
return JsonResponse::errorFromThrowable($e);
return JsonResponse::fail($e->getMessage(), Http::STATUS_NOT_FOUND);
}

$appointmentConfig->setName($name);
Expand All @@ -284,7 +284,7 @@ public function update(
return JsonResponse::success($appointmentConfig);
} catch (ServiceException $e) {
$this->logger->error('Could not update configuration with id ' . $id, ['exception' => $e]);
return JsonResponse::errorFromThrowable($e, 403);
return JsonResponse::fail($e->getMessage(), Http::STATUS_INTERNAL_SERVER_ERROR);
}
}

Expand All @@ -303,7 +303,7 @@ public function destroy(int $id): JsonResponse {
return JsonResponse::success();
} catch (ServiceException $e) {
$this->logger->error('Could not delete configuration with id ' . $id, ['exception' => $e]);
return JsonResponse::errorFromThrowable($e, 403);
return JsonResponse::fail($e->getMessage(), Http::STATUS_INTERNAL_SERVER_ERROR);
}
}
}
4 changes: 3 additions & 1 deletion src/services/appointmentConfigService.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import logger from '../utils/logger.js'
* @return {Promise<AppointmentConfig>} Full appointment config with an id
*/
export async function createConfig(config) {
logger.debug('Creating appointment config', { config })
const url = generateUrl('/apps/calendar/v1/appointment_configs')

const response = await axios.post(url, config)
Expand All @@ -45,6 +46,7 @@ export async function createConfig(config) {
* @return {Promise<void>}
*/
export async function deleteConfig(id) {
logger.debug('Deleting appointment config', { id })
const url = generateUrl('/apps/calendar/v1/appointment_configs/{id}', {
id,
})
Expand All @@ -59,7 +61,7 @@ export async function deleteConfig(id) {
* @return {Promise<AppointmentConfig>} Updated appointment config as stored in the backend
*/
export async function updateConfig(config) {
logger.info('Deleting config', { config, id: config.id })
logger.debug('Updating appointment config', { config })
const url = generateUrl('/apps/calendar/v1/appointment_configs/{id}', {
id: config.id,
})
Expand Down
4 changes: 2 additions & 2 deletions tests/php/unit/Controller/AppointmentConfigControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ public function testUpdateNotFound(): void {
5 * 60
);

self::assertEquals(500, $response->getStatus());
self::assertEquals(404, $response->getStatus());
}

public function testUpdateDBException(): void {
Expand Down Expand Up @@ -319,6 +319,6 @@ public function testUpdateDBException(): void {
5 * 60
);

self::assertEquals(403, $response->getStatus());
self::assertEquals(500, $response->getStatus());
}
}