Skip to content

훅에서 throw new Error로 반환한 에러메시지가 Image is not defined로 출력되는 문제 #93

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

Open
suhyeoonn opened this issue Oct 21, 2024 · 0 comments
Assignees
Labels
bug Something isn't working

Comments

@suhyeoonn
Copy link
Contributor

문제 설명

훅에서 아래와 같이 에러 메시지를 반환할 때, 해당 라이브러리를 import하여 훅을 사용할 경우 예상한 에러 메시지가 아닌 ReferenceError: Image is not defined 에러가 발생하는 문제가 있습니다.

if (!validators.isClient()) {
  console.log("server call");
  throw new Error(
    "localStorage is not available in this environment. Please ensure you are running this code in a browser."
  );
}

확인 방법

Next.js에서 라이브러리를 import하여 useLocalStorage 훅을 사용할 때, 500 에러 코드와 함께 ReferenceError: Image is not defined 에러가 발생합니다.
반면, useLocalStorage 코드를 그대로 복사하여 프로젝트 내에서 직접 사용하면, “localStorage is not available in this environment. Please ensure you are running this code in a browser.” 라는 정확한 에러 메시지가 출력됩니다.

결론

라이브러리에서 반환되는 에러 메시지가 프로젝트 내에서 사용할 때와 다르게 출력되는 문제로 보이며, 원인 및 해결 방법을 확인 중입니다.
또한, #91 이슈에서도 동일한 에러 메시지가 발생하는 것으로 보아 실제로 출력되어야 할 에러 메시지가 제대로 전달되지 않은 것으로 추정됩니다.

@suhyeoonn suhyeoonn self-assigned this Oct 21, 2024
@suhyeoonn suhyeoonn added the bug Something isn't working label Oct 21, 2024
@suhyeoonn suhyeoonn changed the title 커스텀 훅에서 throw new Error로 반환한 에러메시지가 Image is not defined로 출력되는 문제 훅에서 throw new Error로 반환한 에러메시지가 Image is not defined로 출력되는 문제 Oct 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant