René's URL Explorer Experiment


Title: 70. 복구할 수 있는 상황에는 검사 예외를, 프로그래밍 오류에는 런타임 예외를 사용하라 · Issue #165 · Study-2-Effective-Java/Effective-Java · GitHub

Open Graph Title: 70. 복구할 수 있는 상황에는 검사 예외를, 프로그래밍 오류에는 런타임 예외를 사용하라 · Issue #165 · Study-2-Effective-Java/Effective-Java

X Title: 70. 복구할 수 있는 상황에는 검사 예외를, 프로그래밍 오류에는 런타임 예외를 사용하라 · Issue #165 · Study-2-Effective-Java/Effective-Java

Description: Discussed in https://github.com/orgs/Study-2-Effective-Java/discussions/164 Originally posted by JoisFe March 20, 2023 70. 복구할 수 있는 상황에는 검사 예외를, 프로그래밍 오류에는 런타임 예외를 사용하라 throwable (문제 상황을 알리는 타입) 자바는 throwable로 검사 예외, 런타임 예외, 에러 이렇게 3가지를 ...

Open Graph Description: Discussed in https://github.com/orgs/Study-2-Effective-Java/discussions/164 Originally posted by JoisFe March 20, 2023 70. 복구할 수 있는 상황에는 검사 예외를, 프로그래밍 오류에는 런타임 예외를 사용하라 throwable (문제 상황을 알리는 타입) 자바...

X Description: Discussed in https://github.com/orgs/Study-2-Effective-Java/discussions/164 Originally posted by JoisFe March 20, 2023 70. 복구할 수 있는 상황에는 검사 예외를, 프로그래밍 오류에는 런타임 예외를 사용하라 throwable (문제 상황을 알리는 타입) 자바...

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

X: @github

direct link

Domain: patch-diff.githubusercontent.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"70. 복구할 수 있는 상황에는 검사 예외를, 프로그래밍 오류에는 런타임 예외를 사용하라","articleBody":"### Discussed in https://github.com/orgs/Study-2-Effective-Java/discussions/164\r\n\r\n\u003cdiv type='discussions-op-text'\u003e\r\n\r\n\u003csup\u003eOriginally posted by **JoisFe** March 20, 2023\u003c/sup\u003e\r\n# 70. 복구할 수 있는 상황에는 검사 예외를, 프로그래밍 오류에는 런타임 예외를 사용하라\r\n\r\n### throwable (문제 상황을 알리는 타입)\r\n- 자바는 throwable로 검사 예외, 런타임 예외, 에러 이렇게 3가지를 제공\r\n- 이 3가지를 언제 무엇을 사용해야하는지 헷갈리는 경우가 있음\r\n\r\n## 검사 예외, 런타임 예외, 에러 3가지를 언제 무엇을 사용할지 지침\r\n- 앞으로의 지침이 100% 명확한 것은 아님!!\r\n\r\n### 1. 호출하는 쪽에서 복구하리라 여겨지는 상황이라면 검사 예외를 사용\r\n- 이 지침이 검사와 비검사 예외를 구분하는 기본 규칙\r\n- 검사 예외를 던지면 호출자가 그 예외를 catch로 잡아 처리하거나 더 바깥으로 전파하도록 강제하게 됨\r\n- --\u003e 메서드 선언에 포함된 검사 예외 각각은 그 메서드를 호출했을 때 발생할 수 있는 유력한 결과임을 API 사용자에게 알림\r\n- (API 설계자는 API 사용자에게 검사 예외를 던져 그 상황에서 회복시키라 요구)\r\n- 물론 사용자는 예외를 잡기만 하고 별 조치를 취하지 않을 수 있음 다만 이는 좋지 않음 (아이템 77 참고)\r\n\r\n### 비검사 throwable 2 가지\r\n1. 런타임 에러\r\n2. 에러\r\n\r\n- 공통점 : 프로그램에서 잡을 필요가 없거나 혹은 통상적으로는 잡지 말아야 함\r\n- 프로그램에서 비검사 예외 혹은 에러를 던졌다는 것은 복구가 불가능하거나 더 실행해봐야 득보다 실이 더 많다는 뜻\r\n- 해당 throwable을 잡지 않은 스레드는 적절한 오류 메시지를 내뱉으며 중단됨\r\n\r\n### 2. 프로그램 오류를 나타낼 때는 런타임 예외를 사용\r\n- 런타임 예외의 대부분 경우 전제조건을 만족하지 못한 경우\r\n\r\n### 전제조건 위배 \r\n- 단순히 클라이언트가 해당 API의 명세에 기록된 제약을 지키지 못했다는 뜻\r\n- ex) `ArrayIndexOutOfBoundsException : 배열의 인덱스는 0에서 배열 크기 -1 사이` 여야하는 전제조건을 지키지 못한 것\r\n\r\n### 제약은 조건에서 문제가 하나 있다면 복구할 수 있는 상황인지 프로그래밍 오류인지가 항상 명확히 구분되지  않음\r\n- ex) 자원 고갈은 말도 안 되는 크기의 배열을 할당해 생긴 프로그래밍 오류일 수도 있고, 진짜로 자원이 부족해서 발생한 문제일 수 있음. 만약 자원이 일시적으로 부족하거나 수요가 순간적으로 몰린 것이라면 충분히 복구 가능\r\n- 즉 복구될 수 있는지 없는지의 판단의 API 설계자의 몫\r\n\r\n### 위의 판단을 내리지 못할 경우 즉 확신하기 어렵다면 아마도 비검사 예외를 선택하는 편이 나음\r\n- 해당 이유는 아이템 71 참고\r\n\r\n### 3. 구현하는 비검사 throwable은 모두 RuntimeException의 하위 클래스여야 함 (직접적이든 간접적이든)\r\n- 에러는 보통 JVM이 자원 부족, 불변식 깨짐 등 더 이상 수행을 계속할 수 없는 상황을 나타낼 때 사용\r\n- 자바 언어 명세가 요구하는 것은 아니지만 업계에 널리 퍼진 규약\r\n- Error 클래스를 상속해 하위 클래스를 만드는 일은 자제 (Error를 상속하지 말아야)\r\n- 또한 throw 문으로 직접 던지는 일도 없어야 함 (AssertionError 경우 예외)\r\n\r\n## throwable을 언제 사용?\r\n- Exception, RuntimeException, Error을 상속하지 않는 throwable을 만들 수도 있음\r\n- 자바 언어 명세에서 이런 throwable을 직접 다루지는 않지만 암묵적으로 일반적인 검사 예외 (Exceptiond의 하위 클래스 중 RuntimeException을 상속하지 않은) 처럼 다룸\r\n\r\n### throwable은 이로울 게 없으니 절대 사용하지 말아야 함!!!!!!\r\n- throwable 경우 정상적인 검사 예외보다 나을 게 하나도 없으면서 API 사용자를 헷갈리게 할 뿐\r\n- API 설계자 또한 예외 역시 어떤 메서드라도 정의할 수 있는 완벽한 객체라는 사실을 잊곤 함...\r\n\r\n## 예외의 메서드\r\n- 예외의 메서드 경우 주로 그 예외를 일으킨 상황에 대한 정보를 코드 형태로 전달하는데 쓰임\r\n- 이런 메서드가 존재하지 않는다면 프로그래머들은 오류 메시지를 파싱해 정보를 빼내야하는 불편함을 겪게 될 것임 (이러한 습관은 매우 나쁨 #32 참고)\r\n- throwable 클래스들 대부분은 오류 메시지 포맷을 상세히 기술하지 않는데 이는 JVM이나 릴리스에 따라 포맷이 달라질 수 있기 때문임\r\n- --\u003e 메시지 문자열을 파싱해 얻은 코드는 깨지기 쉽고 다른 환경에서 동작하지 않을 수 있음\r\n\r\n### 검사 예외와 예외의 메서드\r\n- 검사 예외는 일반적으로 복구할 수 있는 조건일 때 발생\r\n- --\u003e 호출자가 예외 상황에서 벗어나는 데 필요한 정보를 알려주는 메서드를 함께 제공하는 것이 중요\r\n\r\n## 정리\r\n- 복구할 수 있는 상황이면 --\u003e 검사 예외\r\n- 프로그래밍 오류라면 --\u003e 비검사 예외\r\n- 확실 하지 않다면 --\u003e 비검사 예외\r\n- 검사 예외도 아니고 런타임 예외도 아닌 throwable은 정의하지 말아!!\r\n- 검사 예외 경우 복구에 필요한 정보를 알려주는 메서드를 제공하자!\u003c/div\u003e","author":{"url":"https://github.com/JoisFe","@type":"Person","name":"JoisFe"},"datePublished":"2023-03-20T12:20:07.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":0},"url":"https://github.com/165/Effective-Java/issues/165"}

route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:976ad321-a315-c83f-dc4b-7ddbad46d1a4
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-id80AE:2ABBC9:1CF9D7:27C039:696E6B43
html-safe-noncec014a2c92d1d16b54736b768a921ccf8095102b762531370ddff96e80c637034
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4MEFFOjJBQkJDOToxQ0Y5RDc6MjdDMDM5OjY5NkU2QjQzIiwidmlzaXRvcl9pZCI6IjU1NTAxNTU4MjYyNzkxMTU1ODciLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ==
visitor-hmac88fa85ea65d21719c0680a83a9c9dca429444f88769e235566117152427751d3
hovercard-subject-tagissue:1631997213
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/165/issue_layout
twitter:imagehttps://opengraph.githubassets.com/f2b46ff2ce825af89a6da9b3b03bfa0fff6e3bfaa3da633139f1a31df1b1ca2b/Study-2-Effective-Java/Effective-Java/issues/165
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/f2b46ff2ce825af89a6da9b3b03bfa0fff6e3bfaa3da633139f1a31df1b1ca2b/Study-2-Effective-Java/Effective-Java/issues/165
og:image:altDiscussed in https://github.com/orgs/Study-2-Effective-Java/discussions/164 Originally posted by JoisFe March 20, 2023 70. 복구할 수 있는 상황에는 검사 예외를, 프로그래밍 오류에는 런타임 예외를 사용하라 throwable (문제 상황을 알리는 타입) 자바...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernameJoisFe
hostnamegithub.com
expected-hostnamegithub.com
Nonedd24262d9e4947a6c63df018b01e9a6da49caaf8259148a56a04b665d15d66b3
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
release307ab96ec5f21762ff6c530a60b1ef6b1e74dd5a
ui-targetcanary-2
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://patch-diff.githubusercontent.com/Study-2-Effective-Java/Effective-Java/issues/165#start-of-content
https://patch-diff.githubusercontent.com/
Sign in https://patch-diff.githubusercontent.com/login?return_to=https%3A%2F%2Fgithub.com%2FStudy-2-Effective-Java%2FEffective-Java%2Fissues%2F165
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://patch-diff.githubusercontent.com/login?return_to=https%3A%2F%2Fgithub.com%2FStudy-2-Effective-Java%2FEffective-Java%2Fissues%2F165
Sign up https://patch-diff.githubusercontent.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://patch-diff.githubusercontent.com/Study-2-Effective-Java/Effective-Java/issues/165
Reloadhttps://patch-diff.githubusercontent.com/Study-2-Effective-Java/Effective-Java/issues/165
Reloadhttps://patch-diff.githubusercontent.com/Study-2-Effective-Java/Effective-Java/issues/165
Study-2-Effective-Java https://patch-diff.githubusercontent.com/Study-2-Effective-Java
Effective-Javahttps://patch-diff.githubusercontent.com/Study-2-Effective-Java/Effective-Java
Notifications https://patch-diff.githubusercontent.com/login?return_to=%2FStudy-2-Effective-Java%2FEffective-Java
Fork 3 https://patch-diff.githubusercontent.com/login?return_to=%2FStudy-2-Effective-Java%2FEffective-Java
Star 8 https://patch-diff.githubusercontent.com/login?return_to=%2FStudy-2-Effective-Java%2FEffective-Java
Code https://patch-diff.githubusercontent.com/Study-2-Effective-Java/Effective-Java
Issues 59 https://patch-diff.githubusercontent.com/Study-2-Effective-Java/Effective-Java/issues
Pull requests 0 https://patch-diff.githubusercontent.com/Study-2-Effective-Java/Effective-Java/pulls
Discussions https://patch-diff.githubusercontent.com/Study-2-Effective-Java/Effective-Java/discussions
Actions https://patch-diff.githubusercontent.com/Study-2-Effective-Java/Effective-Java/actions
Projects 0 https://patch-diff.githubusercontent.com/Study-2-Effective-Java/Effective-Java/projects
Security Uh oh! There was an error while loading. Please reload this page. https://patch-diff.githubusercontent.com/Study-2-Effective-Java/Effective-Java/security
Please reload this pagehttps://patch-diff.githubusercontent.com/Study-2-Effective-Java/Effective-Java/issues/165
Insights https://patch-diff.githubusercontent.com/Study-2-Effective-Java/Effective-Java/pulse
Code https://patch-diff.githubusercontent.com/Study-2-Effective-Java/Effective-Java
Issues https://patch-diff.githubusercontent.com/Study-2-Effective-Java/Effective-Java/issues
Pull requests https://patch-diff.githubusercontent.com/Study-2-Effective-Java/Effective-Java/pulls
Discussions https://patch-diff.githubusercontent.com/Study-2-Effective-Java/Effective-Java/discussions
Actions https://patch-diff.githubusercontent.com/Study-2-Effective-Java/Effective-Java/actions
Projects https://patch-diff.githubusercontent.com/Study-2-Effective-Java/Effective-Java/projects
Security https://patch-diff.githubusercontent.com/Study-2-Effective-Java/Effective-Java/security
Insights https://patch-diff.githubusercontent.com/Study-2-Effective-Java/Effective-Java/pulse
New issuehttps://patch-diff.githubusercontent.com/login?return_to=https://github.com/Study-2-Effective-Java/Effective-Java/issues/165
New issuehttps://patch-diff.githubusercontent.com/login?return_to=https://github.com/Study-2-Effective-Java/Effective-Java/issues/165
70. 복구할 수 있는 상황에는 검사 예외를, 프로그래밍 오류에는 런타임 예외를 사용하라https://patch-diff.githubusercontent.com/Study-2-Effective-Java/Effective-Java/issues/165#top
10장 예외이펙티브 자바 10장 (예외)https://github.com/Study-2-Effective-Java/Effective-Java/issues?q=state%3Aopen%20label%3A%2210%EC%9E%A5%20%EC%98%88%EC%99%B8%22
https://github.com/JoisFe
https://github.com/JoisFe
JoisFehttps://github.com/JoisFe
on Mar 20, 2023https://github.com/Study-2-Effective-Java/Effective-Java/issues/165#issue-1631997213
https://github.com/orgs/Study-2-Effective-Java/discussions/164https://github.com/orgs/Study-2-Effective-Java/discussions/164
아이템 12. toString을 항상 재정의하라 #32https://github.com/orgs/Study-2-Effective-Java/discussions/32
10장 예외이펙티브 자바 10장 (예외)https://github.com/Study-2-Effective-Java/Effective-Java/issues?q=state%3Aopen%20label%3A%2210%EC%9E%A5%20%EC%98%88%EC%99%B8%22
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.