{"id":21870230,"url":"https://github.com/qoomon/unchecked-exceptions-java","last_synced_at":"2025-04-14T23:43:52.054Z","repository":{"id":48315278,"uuid":"136159055","full_name":"qoomon/unchecked-exceptions-java","owner":"qoomon","description":"Throw any Java Exception anywhere without the need of catching them nor wrapping them into RuntimeException","archived":false,"fork":false,"pushed_at":"2022-10-30T14:50:22.000Z","size":75,"stargazers_count":8,"open_issues_count":6,"forks_count":4,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-14T23:43:47.123Z","etag":null,"topics":["checkedexception","exception-handling","exceptions","java","rethrow-exceptions","throw","unchecked-exception","wrapping"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/qoomon.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-06-05T10:12:18.000Z","updated_at":"2024-12-07T14:29:52.000Z","dependencies_parsed_at":"2022-09-21T11:30:39.297Z","dependency_job_id":null,"html_url":"https://github.com/qoomon/unchecked-exceptions-java","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/qoomon%2Funchecked-exceptions-java","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/qoomon%2Funchecked-exceptions-java/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/qoomon%2Funchecked-exceptions-java/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/qoomon%2Funchecked-exceptions-java/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/qoomon","download_url":"https://codeload.github.com/qoomon/unchecked-exceptions-java/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248981259,"owners_count":21193143,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["checkedexception","exception-handling","exceptions","java","rethrow-exceptions","throw","unchecked-exception","wrapping"],"created_at":"2024-11-28T06:10:44.329Z","updated_at":"2025-04-14T23:43:52.036Z","avatar_url":"https://github.com/qoomon.png","language":"Java","readme":"# Unchecked Exception \n\n[![Build](https://github.com/qoomon/unchecked-exceptions-java/actions/workflows/build.yml/badge.svg)](https://github.com/qoomon/unchecked-exceptions-java/actions/workflows/build.yml)\n\n[![Known Vulnerabilities](https://snyk.io/test/github/qoomon/unchecked-exceptions-java/badge.svg)](https://snyk.io/test/github/qoomon/unchecked-exceptions-java)\n\n[![Maintainability](https://api.codeclimate.com/v1/badges/d8d4132d4737c4c34edd/maintainability)](https://codeclimate.com/github/qoomon/unchecked-exceptions-java/maintainability)\n\n[![Test Coverage](https://api.codeclimate.com/v1/badges/d8d4132d4737c4c34edd/test_coverage)](https://codeclimate.com/github/qoomon/unchecked-exceptions-java/test_coverage)\n\n[![Maven Central](https://img.shields.io/maven-central/v/me.qoomon/unchecked-exceptions.svg)](http://search.maven.org/#search%7Cga%7C1%7Cg%3A%22me.qoomon%22%20AND%20a%3A%22unchecked-exceptions%22) \n\nThis lib hase **zero dependencies** and can be used to throw checked exceptions without declaring this in your method's head `throws` clause.\nAnd without wrapping `Exception` into a `RuntimeException`. Basically you can throw any `Exception` everywhere without catching them, happy throwing :-D\n\n\n\n## Methods\n\n`unchecked(Exception)` rethrows any exception as unchecked exception, without wrapping exception.\n```java\n  throw unchecked(checkedException);\n```\n\n`unchecked(LambdaFunction)` returns result or rethrows exception from lambda function as unchecked exception, without wrapping exception.\n```java\n  return unchecked(() -\u003e methodThrowingCheckedException())\n```\n\n## Usage Examples\n### Try-Catch Block\n#### Regular Code \n```java\n  import static me.qoomon.UncheckedExceptions.*;\n\n  public class Example {\n      \n      void example() {\n          URL url;\n          // code polition with try catch block\n          try {\n            url = new URL(\"https:/www.example.org\");\n          } catch (MalformedURLException e) {\n            // ugly exception wrapping\n            throw RuntimeException(e); \n          }\n          System.out(url);\n      }\n  }\n```\n#### Unchecked Exception Code\n```java\n  import static me.qoomon.UncheckedExceptions.*;\n\n  public class Example {\n      \n      void example() {\n        // get rid of code polition with try catch block and exception wrapping\n        URL url = unchecked(() -\u003e new URL(\"https:/www.example.org\"));\n        System.out(url);\n      }\n  }\n```\n### Stream\n#### Regular Code \n```java\n  \n    import static me.qoomon.UncheckedExceptions.*;\n  \n    public class Example {\n        \n        void example() {\n          Stream.of(\"https:/www.example.org\")\n            .map(url -\u003e {\n              // code polition with try catch block\n              try {\n                return new URL(url);\n              } catch (MalformedURLException e) {\n                // ugly exception wrapping\n                throw new RuntimeException(e);\n              }\n            });\n        }\n    }\n```\n#### Unchecked Exception Code\n```java\n  \n    import static me.qoomon.UncheckedExceptions.*;\n  \n    public class Example {\n        \n        void example() {\n            Stream.of(\"https:/www.example.org\")\n                // get rid of code polition with try catch block and exception wrapping\n                .map(url -\u003e unchecked(() -\u003e new URL(url)));\n            }\n    }\n```\n\n \n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fqoomon%2Funchecked-exceptions-java","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fqoomon%2Funchecked-exceptions-java","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fqoomon%2Funchecked-exceptions-java/lists"}