René's URL Explorer Experiment


Title: 아이템 75. 예외의 상세 메시지에 실패 관련 정보를 담으라 · Issue #180 · Study-2-Effective-Java/Effective-Java · GitHub

Open Graph Title: 아이템 75. 예외의 상세 메시지에 실패 관련 정보를 담으라 · Issue #180 · Study-2-Effective-Java/Effective-Java

X Title: 아이템 75. 예외의 상세 메시지에 실패 관련 정보를 담으라 · Issue #180 · Study-2-Effective-Java/Effective-Java

Description: Discussed in https://github.com/orgs/Study-2-Effective-Java/discussions/179 Originally posted by JoisFe March 26, 2023 아이템 75. 예외의 상세 메시지에 실패 관련 정보를 담으라 스택 추적 (Stack Trace) 예외를 잡지 못해 프로그램이 실패하면 자바 시스템은 그 예외의 스택 추적 정보를 자동으로 출력 스택 추적은 예외 객...

Open Graph Description: Discussed in https://github.com/orgs/Study-2-Effective-Java/discussions/179 Originally posted by JoisFe March 26, 2023 아이템 75. 예외의 상세 메시지에 실패 관련 정보를 담으라 스택 추적 (Stack Trace) 예외를 잡지 못해 프로그램이 실패하면 자바 ...

X Description: Discussed in https://github.com/orgs/Study-2-Effective-Java/discussions/179 Originally posted by JoisFe March 26, 2023 아이템 75. 예외의 상세 메시지에 실패 관련 정보를 담으라 스택 추적 (Stack Trace) 예외를 잡지 못해 프로그램이 실패하면 자바 ...

Opengraph URL: https://github.com/Study-2-Effective-Java/Effective-Java/issues/180

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"아이템 75. 예외의 상세 메시지에 실패 관련 정보를 담으라","articleBody":"### Discussed in https://github.com/orgs/Study-2-Effective-Java/discussions/179\r\n\r\n\u003cdiv type='discussions-op-text'\u003e\r\n\r\n\u003csup\u003eOriginally posted by **JoisFe** March 26, 2023\u003c/sup\u003e\r\n# 아이템 75. 예외의 상세 메시지에 실패 관련 정보를 담으라\r\n\r\n## 스택 추적 (Stack Trace)\r\n- 예외를 잡지 못해 프로그램이 실패하면 자바 시스템은 그 예외의 스택 추적 정보를 자동으로 출력\r\n- 스택 추적은 예외 객체의 toString 메서드를 호출해 얻는 문자열 (보통은 예외의 클래스 이름 뒤에 상세 메시지가 붙는 형태)\r\n- 해당 정보가 실패 원인을 분석해야 하는 프로그래머 혹은 SRE (Site Reliability Engineer, SRE)가 얻을 수 있는 유일한 정보인 경우가 많음\r\n- 또한 실패를 재현하기 어렵다면 더 자세한 정보를 얻기 어렵거나 불가능함\r\n\r\n### 예외의 toString 메서드에 실패 원인에 관한 정보를 가능한 많이 담아 반환하는 일은 매우 중요\r\n- 사후 분석을 위해 실패 순간의 상황을 정확히 포착해 예외의 상세 메시지에 담아야 함!\r\n\r\n## 예외의 상세 메시지를 작성하는 방법\r\n### 실패 순간을 포착하려면 발생한 예외에 관련된 모든 매개변수와 필드의 값을 실패 메시지에 담아야 함\r\n\r\n- EX) IndexOutOfBoundsException의 상세 메시지는 범위의 최솟값과 최댓값, 그리고 그 범위를 벗어났다는 인덱스의 값을 담아야 함\r\n- (해당 정보는 실패에 관한 많은 것을 알려줌)\r\n- 셋 중 한두 개 혹은 셋 모두가 잘못됐을 수 있기 때문\r\n- 이상의 현상들은 모두 원인이 다르므로 현상을 보면 무엇을 고쳐야 할지를 분석하는데 도움이 됨\r\n- 관련 데이터를 모두 담아야 하지만 장황할 필요는 없음 (문제를 분석하는 사람은 스택 추척뿐만 아니라 관련 문서, 소스코드를 함께 살펴보기 때문)\r\n\r\n### 예외의 상세 메시지와 최종 사용자에게 보여줄 오류 메시지를 혼동해선 안됨\r\n- 최종 사용자에게는 친절한 안내 메시지를 보여줘야 함\r\n- 반면 예외 메시지는 가독성 보단 담긴 내용이 훨씬 중요\r\n- 예외 메시지의 주 소비층은 문제를 분석해야 할 프로그래머와 SRE 엔지니어 이기 때문\r\n\r\n### 실패를 적절히 포착하려면 필요한 정보를 예외 생성자에서 모두 받아서 상세 메시지까지 미리 생성해놓는 방법 또한 괜찮음\r\n- EX) 현재의 IndexOutOfBoundsException 생성자는 String을 받지만 아래의 예시 코드와 같이 구현해도 좋음\r\n``` java\r\n    /**\r\n     * IndexOutOfBoundsException을 생성한다.\r\n     * \r\n     * @param lowerBound 인덱스의 최솟값\r\n     * @param upperBound 인덱스의 최댓값 + 1\r\n     * @param index 인덱스의 실젯값\r\n     */\r\n    public IndexOutOfBoundsException(int lowerBound, int upperBound, int index) {\r\n        // 실패를 포착하는 상세 메시지를 생성한다.\r\n        super(String.format(\"최솟값: %d, 최댓값: %d, 인덱스: %d\", lowerBound, upperBound, index));\r\n        \r\n        // 프로그램에서 이용할 수 있도록 실패 정보를 저장해둠.\r\n        this.lowerBound = lowerBound;\r\n        this.upperBound = upperBound;\r\n        this.index = index;\r\n    }\r\n```\r\n\r\n- 자바 9에서는 IndexOutOfBoundsException에 드디어 정수 인덱스 값을 받는 생성자가 추가되었음\r\n- 하지만 아쉽게도 최솟값과 최댓값까지 받지는 않음\r\n- 이처럼 자바 라이브러리에서 이 조언을 적극 수용하진 않았지만 위 같은 코드처럼 권장함!\r\n- 이렇게 하면 프로그래머가 던지는 예외는 자연스럽게 실패를 더 잘 포착함\r\n- 또한 고품질의 상세 메시지를 만들어내는 코드를 예외 클래스 안으로 모아주는 효과가 있음\r\n- 따라서 클래스 사용자가 메시지를 만드는 작업을 중복하지 않아도 됨\r\n\r\n### 예외는 실패와 관련한 정보를 얻을 수 있는 접근자 메서드를 적절히 제공하는 것이 좋음\r\n- 위 내용은 #164 참고\r\n- 앞의 예시 코드를 예로 들면 lowerBound, upperBound, index 정도가 적당\r\n- 포착한 실패 정보는 예외 상황을 복구하는 데 유용할 수 있으므로 접근자 메서드는 비검사 예외보다는 검사 예외에서 더 빛을 발함\r\n- 비검사 예외의 상세 정보에 프로그램적으로 접근하길 원하는 프로그래머는 드물 것이지만 (전혀 없지는 않음)\r\n- 하지만 `toString이 반환한 값에 포함된 정보를 얻어올 수 있는 API를 제공하자` 일반 원칙을 따른다는 관점에서는 비검사 예외에도 상세 정보를 알려주는 접근자 메서드를 제공하는 것을 권함!\u003c/div\u003e","author":{"url":"https://github.com/JoisFe","@type":"Person","name":"JoisFe"},"datePublished":"2023-03-26T14:01:06.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":0},"url":"https://github.com/180/Effective-Java/issues/180"}

route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:c368d0dc-6c6b-804f-235b-9d4f8f406cf3
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-id8CAA:25678D:722505:9C94CA:696F288A
html-safe-nonce0f7ba7c9ddc8c90a1798fabf503da2acbd5ce1af787917f547bd1e65577953de
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4Q0FBOjI1Njc4RDo3MjI1MDU6OUM5NENBOjY5NkYyODhBIiwidmlzaXRvcl9pZCI6IjExMzMwNDI5NTQ2MjA4NDAwNzQiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ==
visitor-hmacf97a3a071f5aca542143d87203d54c160bb304da85fd68baba3a44481be629b9
hovercard-subject-tagissue:1640923534
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/Study-2-Effective-Java/Effective-Java/180/issue_layout
twitter:imagehttps://opengraph.githubassets.com/d2592151b6909f09d6bcca1b6cddabad43b14eca5a21ebf78237ade6f78877cb/Study-2-Effective-Java/Effective-Java/issues/180
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/d2592151b6909f09d6bcca1b6cddabad43b14eca5a21ebf78237ade6f78877cb/Study-2-Effective-Java/Effective-Java/issues/180
og:image:altDiscussed in https://github.com/orgs/Study-2-Effective-Java/discussions/179 Originally posted by JoisFe March 26, 2023 아이템 75. 예외의 상세 메시지에 실패 관련 정보를 담으라 스택 추적 (Stack Trace) 예외를 잡지 못해 프로그램이 실패하면 자바 ...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernameJoisFe
hostnamegithub.com
expected-hostnamegithub.com
Noneb278ad162d35332b6de714dfb005de04386c4d92df6475522bef910f491a35ee
turbo-cache-controlno-preview
go-importgithub.com/Study-2-Effective-Java/Effective-Java git https://github.com/Study-2-Effective-Java/Effective-Java.git
octolytics-dimension-user_id120388640
octolytics-dimension-user_loginStudy-2-Effective-Java
octolytics-dimension-repository_id577325341
octolytics-dimension-repository_nwoStudy-2-Effective-Java/Effective-Java
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id577325341
octolytics-dimension-repository_network_root_nwoStudy-2-Effective-Java/Effective-Java
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release39aed5006635ab6f45e6b77d23e73b08a00272a3
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/Study-2-Effective-Java/Effective-Java/issues/180#start-of-content
https://github.com/
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2FStudy-2-Effective-Java%2FEffective-Java%2Fissues%2F180
GitHub CopilotWrite better code with AIhttps://github.com/features/copilot
GitHub SparkBuild and deploy intelligent appshttps://github.com/features/spark
GitHub ModelsManage and compare promptshttps://github.com/features/models
MCP RegistryNewIntegrate external toolshttps://github.com/mcp
ActionsAutomate any workflowhttps://github.com/features/actions
CodespacesInstant dev environmentshttps://github.com/features/codespaces
IssuesPlan and track workhttps://github.com/features/issues
Code ReviewManage code changeshttps://github.com/features/code-review
GitHub Advanced SecurityFind and fix vulnerabilitieshttps://github.com/security/advanced-security
Code securitySecure your code as you buildhttps://github.com/security/advanced-security/code-security
Secret protectionStop leaks before they starthttps://github.com/security/advanced-security/secret-protection
Why GitHubhttps://github.com/why-github
Documentationhttps://docs.github.com
Bloghttps://github.blog
Changeloghttps://github.blog/changelog
Marketplacehttps://github.com/marketplace
View all featureshttps://github.com/features
Enterpriseshttps://github.com/enterprise
Small and medium teamshttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
App Modernizationhttps://github.com/solutions/use-case/app-modernization
DevSecOpshttps://github.com/solutions/use-case/devsecops
DevOpshttps://github.com/solutions/use-case/devops
CI/CDhttps://github.com/solutions/use-case/ci-cd
View all use caseshttps://github.com/solutions/use-case
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
View all industrieshttps://github.com/solutions/industry
View all solutionshttps://github.com/solutions
AIhttps://github.com/resources/articles?topic=ai
Software Developmenthttps://github.com/resources/articles?topic=software-development
DevOpshttps://github.com/resources/articles?topic=devops
Securityhttps://github.com/resources/articles?topic=security
View all topicshttps://github.com/resources/articles
Customer storieshttps://github.com/customer-stories
Events & webinarshttps://github.com/resources/events
Ebooks & reportshttps://github.com/resources/whitepapers
Business insightshttps://github.com/solutions/executive-insights
GitHub Skillshttps://skills.github.com
Documentationhttps://docs.github.com
Customer supporthttps://support.github.com
Community forumhttps://github.com/orgs/community/discussions
Trust centerhttps://github.com/trust-center
Partnershttps://github.com/partners
GitHub SponsorsFund open source developershttps://github.com/sponsors
Security Labhttps://securitylab.github.com
Maintainer Communityhttps://maintainers.github.com
Acceleratorhttps://github.com/accelerator
Archive Programhttps://archiveprogram.github.com
Topicshttps://github.com/topics
Trendinghttps://github.com/trending
Collectionshttps://github.com/collections
Enterprise platformAI-powered developer platformhttps://github.com/enterprise
GitHub Advanced SecurityEnterprise-grade security featureshttps://github.com/security/advanced-security
Copilot for BusinessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/premium-support
Pricinghttps://github.com/pricing
Search syntax tipshttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
documentationhttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2FStudy-2-Effective-Java%2FEffective-Java%2Fissues%2F180
Sign up https://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=Study-2-Effective-Java%2FEffective-Java
Reloadhttps://github.com/Study-2-Effective-Java/Effective-Java/issues/180
Reloadhttps://github.com/Study-2-Effective-Java/Effective-Java/issues/180
Reloadhttps://github.com/Study-2-Effective-Java/Effective-Java/issues/180
Study-2-Effective-Java https://github.com/Study-2-Effective-Java
Effective-Javahttps://github.com/Study-2-Effective-Java/Effective-Java
Notifications https://github.com/login?return_to=%2FStudy-2-Effective-Java%2FEffective-Java
Fork 3 https://github.com/login?return_to=%2FStudy-2-Effective-Java%2FEffective-Java
Star 8 https://github.com/login?return_to=%2FStudy-2-Effective-Java%2FEffective-Java
Code https://github.com/Study-2-Effective-Java/Effective-Java
Issues 59 https://github.com/Study-2-Effective-Java/Effective-Java/issues
Pull requests 0 https://github.com/Study-2-Effective-Java/Effective-Java/pulls
Discussions https://github.com/Study-2-Effective-Java/Effective-Java/discussions
Actions https://github.com/Study-2-Effective-Java/Effective-Java/actions
Projects 0 https://github.com/Study-2-Effective-Java/Effective-Java/projects
Security Uh oh! There was an error while loading. Please reload this page. https://github.com/Study-2-Effective-Java/Effective-Java/security
Please reload this pagehttps://github.com/Study-2-Effective-Java/Effective-Java/issues/180
Insights https://github.com/Study-2-Effective-Java/Effective-Java/pulse
Code https://github.com/Study-2-Effective-Java/Effective-Java
Issues https://github.com/Study-2-Effective-Java/Effective-Java/issues
Pull requests https://github.com/Study-2-Effective-Java/Effective-Java/pulls
Discussions https://github.com/Study-2-Effective-Java/Effective-Java/discussions
Actions https://github.com/Study-2-Effective-Java/Effective-Java/actions
Projects https://github.com/Study-2-Effective-Java/Effective-Java/projects
Security https://github.com/Study-2-Effective-Java/Effective-Java/security
Insights https://github.com/Study-2-Effective-Java/Effective-Java/pulse
New issuehttps://github.com/login?return_to=https://github.com/Study-2-Effective-Java/Effective-Java/issues/180
New issuehttps://github.com/login?return_to=https://github.com/Study-2-Effective-Java/Effective-Java/issues/180
아이템 75. 예외의 상세 메시지에 실패 관련 정보를 담으라https://github.com/Study-2-Effective-Java/Effective-Java/issues/180#top
https://github.com/JoisFe
https://github.com/JoisFe
JoisFehttps://github.com/JoisFe
on Mar 26, 2023https://github.com/Study-2-Effective-Java/Effective-Java/issues/180#issue-1640923534
https://github.com/orgs/Study-2-Effective-Java/discussions/179https://github.com/orgs/Study-2-Effective-Java/discussions/179
아이템 70. 복구할 수 있는 상황에는 검사 예외를, 프로그래밍 오류에는 런타임 예외를 사용하라 #164https://github.com/orgs/Study-2-Effective-Java/discussions/164
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.