feat(api): 특정 IP에서 발생하는 예외 슬랙/로그 제외 기능

- EXCEPTION_IGNORED_IPS 환경변수로 무시할 IP 목록 관리
- 해당 IP에서 '회원정보 정보 없음' 예외 발생 시 슬랙/로그 건너뜀
- 사무실/개발자 IP에서 발생하는 불필요한 알림 방지

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2026-01-23 21:08:52 +09:00
parent e285e3eca2
commit 758ce2b988

View File

@@ -16,8 +16,38 @@
class Handler extends ExceptionHandler
{
/**
* 특정 IP에서 발생하는 예외를 슬랙/로그에서 무시할지 확인
*/
protected function shouldIgnoreException(Throwable $e): bool
{
$ignoredIps = array_filter(
array_map('trim', explode(',', env('EXCEPTION_IGNORED_IPS', '')))
);
if (empty($ignoredIps)) {
return false;
}
$currentIp = request()?->ip();
// 무시할 IP 목록에 있고, '회원정보 정보 없음' 예외인 경우
if (in_array($currentIp, $ignoredIps, true)) {
if ($e instanceof AuthenticationException && $e->getMessage() === '회원정보 정보 없음') {
return true;
}
}
return false;
}
public function report(Throwable $e): void
{
// 무시할 예외인 경우 슬랙/로그 모두 건너뜀
if ($this->shouldIgnoreException($e)) {
return;
}
try {
if (
app()->environment('local') || app()->environment('production')