chore(WEB): actions.ts 에러 핸들링 및 CEO 대시보드 개선
- 전체 모듈 actions.ts redirect 에러 핸들링 추가 - CEODashboard DetailModal 추가 - MonthlyExpenseSection 개선 - fetch-wrapper redirect 에러 처리 - redirect-error 유틸 추가 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
38
src/lib/utils/redirect-error.ts
Normal file
38
src/lib/utils/redirect-error.ts
Normal file
@@ -0,0 +1,38 @@
|
||||
/**
|
||||
* Next.js Redirect Error 유틸리티
|
||||
*
|
||||
* Next.js의 redirect() 함수가 throw하는 NEXT_REDIRECT 에러를 감지합니다.
|
||||
*
|
||||
* 왜 자체 구현인가?
|
||||
* - Next.js 내부 경로(next/dist/...)는 버전 업데이트 시 변경될 수 있음
|
||||
* - 공개 API로 제공되지 않는 내부 함수에 의존하지 않기 위함
|
||||
* - 한 곳에서 관리하여 유지보수 용이
|
||||
*
|
||||
* @see https://nextjs.org/docs/app/api-reference/functions/redirect
|
||||
*/
|
||||
|
||||
/**
|
||||
* Next.js redirect() 에러인지 확인
|
||||
*
|
||||
* redirect() 호출 시 Next.js는 특수한 에러를 throw합니다.
|
||||
* 이 에러는 catch 블록에서 잡히면 안 되고, 다시 throw해야 합니다.
|
||||
*
|
||||
* @example
|
||||
* ```typescript
|
||||
* try {
|
||||
* // ... some code that might call redirect()
|
||||
* } catch (error) {
|
||||
* if (isNextRedirectError(error)) throw error;
|
||||
* // handle other errors
|
||||
* }
|
||||
* ```
|
||||
*/
|
||||
export function isNextRedirectError(error: unknown): boolean {
|
||||
return (
|
||||
typeof error === 'object' &&
|
||||
error !== null &&
|
||||
'digest' in error &&
|
||||
typeof (error as { digest: string }).digest === 'string' &&
|
||||
(error as { digest: string }).digest.startsWith('NEXT_REDIRECT')
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user