{"id":25776073,"url":"https://github.com/leakyabstractions/result","last_synced_at":"2026-03-09T10:01:35.359Z","repository":{"id":45806942,"uuid":"324839863","full_name":"LeakyAbstractions/result","owner":"LeakyAbstractions","description":"🎱 A Java library to handle success and failure without exceptions","archived":false,"fork":false,"pushed_at":"2026-02-01T18:48:18.000Z","size":7359,"stargazers_count":37,"open_issues_count":1,"forks_count":0,"subscribers_count":3,"default_branch":"main","last_synced_at":"2026-02-02T03:07:15.824Z","etag":null,"topics":["error-handling","exception-handling","exceptions","functional-programming","java","java-library","library","monad","result"],"latest_commit_sha":null,"homepage":"https://result.leakyabstractions.com","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/LeakyAbstractions.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":"NOTICE","maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null},"funding":{"github":"LeakyAbstractions","ko_fi":"guillermocalvo","custom":"buymeacoffee.com/result"}},"created_at":"2020-12-27T20:07:36.000Z","updated_at":"2026-01-09T16:39:10.000Z","dependencies_parsed_at":"2023-01-31T12:01:30.776Z","dependency_job_id":"d2ee3824-ef81-49c0-b054-631c63d09f77","html_url":"https://github.com/LeakyAbstractions/result","commit_stats":null,"previous_names":[],"tags_count":44,"template":false,"template_full_name":null,"purl":"pkg:github/LeakyAbstractions/result","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LeakyAbstractions%2Fresult","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LeakyAbstractions%2Fresult/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LeakyAbstractions%2Fresult/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LeakyAbstractions%2Fresult/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/LeakyAbstractions","download_url":"https://codeload.github.com/LeakyAbstractions/result/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LeakyAbstractions%2Fresult/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30290904,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-09T02:57:19.223Z","status":"ssl_error","status_checked_at":"2026-03-09T02:56:26.373Z","response_time":61,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["error-handling","exception-handling","exceptions","functional-programming","java","java-library","library","monad","result"],"created_at":"2025-02-27T06:01:17.255Z","updated_at":"2026-03-09T10:01:35.352Z","avatar_url":"https://github.com/LeakyAbstractions.png","language":"Java","funding_links":["https://github.com/sponsors/LeakyAbstractions","https://ko-fi.com/guillermocalvo","buymeacoffee.com/result"],"categories":["REST错误处理"],"sub_categories":[],"readme":"\n[![Build Status][BADGE_BUILD_STATUS]][BUILD_STATUS]\n[![Quality Gate Status][BADGE_QUALITY_GATE]][QUALITY_GATE]\n[![Coverage][BADGE_CODE_COVERAGE]][CODE_COVERAGE]\n[![Maven Central][BADGE_ARTIFACTS]][ARTIFACTS]\n[![Javadoc][BADGE_JAVADOC]][JAVADOC]\n[![Free ebook][BADGE_GUIDE_BOOK]][GUIDE_BOOK]\n\n![][LOGO_DARK]\n![][LOGO_LIGHT]\n\n[![Benchmark Report][BADGE_BENCHMARK]][BENCHMARK]\n\n## A Java library to handle success and failure without exceptions\n\nWave goodbye to slow exceptions and embrace clean, efficient error handling by encapsulating operations that may succeed\nor fail in a type-safe way.\n\n- **Boost Performance**: Avoid exception overhead and benefit from faster operations.\n- **Simple API**: Leverage a familiar interface for a smooth learning curve.\n- **Streamlined Error Handling**: Handle failure explicitly to simplify error propagation.\n- **Safe Execution**: Ensure safer and more predictable operation outcomes.\n- **Enhanced Readability**: Reduce complexity to make your code easier to understand.\n- **Functional Style**: Embrace elegant, functional programming paradigms.\n- **Lightweight**: Keep your project slim with no extra dependencies.\n- **Open Source**: Enjoy transparent, permissive Apache 2 licensing.\n- **Pure Java**: Seamless compatibility from JDK8 to the latest versions.\n\n\u003e [!NOTE]\n\u003e `Result` objects represent the outcome of an operation, removing the need to check for null. Operations that succeed\n\u003e produce results encapsulating a *success* value; operations that fail produce results with a *failure* value. Success\n\u003e and failure can be represented by whatever types make the most sense for each operation.\n\n\n## Results in a Nutshell\n\nIn Java, methods that can fail typically do so by throwing exceptions. Then, exception-throwing methods are called from\ninside a `try` block to handle errors in a separate `catch` block.\n\n![Using Exceptions][USING_EXCEPTIONS]\n\nThis approach is lengthy, and that's not the only problem -- it's also very slow.\n\n\u003e [!TIP]\n\u003e Conventional wisdom says **exceptional logic shouldn't be used for normal program flow**. Results make us deal with\n\u003e expected error situations explicitly to enforce good practices and make our programs [run faster][BENCHMARK].\n\nLet's now look at how the above code could be refactored if `connect()` returned a `Result` object instead of throwing\nan exception.\n\n![Using Results][USING_RESULTS]\n\nIn the example above, we used only 4 lines of code to replace the 10 that worked for the first one. But we can\neffortlessly make it shorter by chaining methods. In fact, since we were returning `-1` just to signal that the\nunderlying operation failed, we are better off returning a `Result` object upstream. This will allow us to compose\noperations on top of `getServerUptime()` just like we did with `connect()`.\n\n![Embracing Results][EMBRACING_RESULTS]\n\n\u003e [!NOTE]\n\u003e `Result` objects are immutable, providing thread safety without the need for synchronization. This makes them ideal\n\u003e for multi-threaded applications, ensuring predictability and eliminating side effects.\n\n\n## Ready to Tap into the Power of Results?\n\nRead the [guide][GUIDE_HOME] and transform your error handling today.\n\n- :seedling: [Getting Started][GUIDE_START]\n- :potted_plant: [Basic Usage][GUIDE_BASIC]\n- :rocket: [Advanced Usage][GUIDE_ADVANCED]\n\nAlso available as an **ebook** in multiple formats. [Download your free copy now!][GUIDE_BOOK]\n\n\n## Releases\n\nThis library adheres to [Pragmatic Versioning][PRAGVER].\n\nArtifacts are available in [Maven Central][ARTIFACTS].\n\n\n## Javadoc\n\nHere you can find the full [Javadoc documentation][JAVADOC].\n\n\n## Benchmarks\n\nYou may want to visualize the latest [benchmark report][BENCHMARK].\n\n\n## Looking for Support?\n\nWe'd love to help. Check out the [support guidelines][SUPPORT].\n\n\n## Contributions Welcome\n\nIf you'd like to contribute to this project, please [start here][CONTRIBUTING].\n\n\n## Code of Conduct\n\nThis project is governed by the [Contributor Covenant Code of Conduct][CODE_OF_CONDUCT].\nBy participating, you are expected to uphold this code.\n\n\n## Author\n\nCopyright 2026 [Guillermo Calvo][AUTHOR].\n\n[![][GUILLERMO_IMAGE]][GUILLERMO]\n\n\n## License\n\nThis library is licensed under the *Apache License, Version 2.0* (the \"License\");\nyou may not use it except in compliance with the License.\n\nYou may obtain a copy of the License at \u003chttp://www.apache.org/licenses/LICENSE-2.0\u003e\n\nUnless required by applicable law or agreed to in writing, software distributed under the License\nis distributed on an \"AS IS\" BASIS, **WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND**, either express or implied.\n\nSee the License for the specific language governing permissions and limitations under the License.\n\n\n**Permitted:**\n\n- **Commercial Use**: You may use this library and derivatives for commercial purposes.\n- **Modification**: You may modify this library.\n- **Distribution**: You may distribute this library.\n- **Patent Use**: This license provides an express grant of patent rights from contributors.\n- **Private Use**: You may use and modify this library without distributing it.\n\n**Required:**\n\n- **License and Copyright Notice**: If you distribute this library you must include a copy of the license and copyright\n  notice.\n- **State Changes**: If you modify and distribute this library you must document changes made to this library.\n\n**Forbidden:**\n\n- **Trademark use**: This license does not grant any trademark rights.\n- **Liability**: The library author cannot be held liable for damages.\n- **Warranty**: This library is provided without any warranty.\n\n\n[ARTIFACTS]:                    https://search.maven.org/artifact/com.leakyabstractions/result/\n[AUTHOR]:                       https://github.com/guillermocalvo/\n[BADGE_ARTIFACTS]:              https://img.shields.io/endpoint?url=https://dev.leakyabstractions.com/result/badge.json\u0026logo=Gradle\u0026label=Maven+Central\u0026labelColor=555\n[BADGE_BENCHMARK]:              https://img.shields.io/endpoint?url=https://dev.leakyabstractions.com/result-benchmark/badge.json\n[BADGE_BUILD_STATUS]:           https://github.com/leakyabstractions/result/workflows/Build/badge.svg\n[BADGE_CODE_COVERAGE]:          https://sonarcloud.io/api/project_badges/measure?project=LeakyAbstractions_result\u0026metric=coverage\n[BADGE_GUIDE_BOOK]:             https://img.shields.io/badge/Free_book-444?logo=leanpub\n[BADGE_JAVADOC]:                https://javadoc.io/badge2/com.leakyabstractions/result/javadoc.svg\n[BADGE_QUALITY_GATE]:           https://sonarcloud.io/api/project_badges/measure?project=LeakyAbstractions_result\u0026metric=alert_status\n[BENCHMARK]:                    https://dev.leakyabstractions.com/result-benchmark/\n[BUILD_STATUS]:                 https://github.com/LeakyAbstractions/result/actions?query=workflow%3ABuild\n[CODE_COVERAGE]:                https://sonarcloud.io/component_measures?id=LeakyAbstractions_result\u0026metric=coverage\u0026view=list\n[CODE_OF_CONDUCT]:              https://github.com/LeakyAbstractions/.github/blob/main/CODE_OF_CONDUCT.md\n[CONTRIBUTING]:                 https://github.com/LeakyAbstractions/.github/blob/main/CONTRIBUTING.md\n[EMBRACING_RESULTS]:            docs/embracing-results.png\n[GUIDE_ADVANCED]:               https://result.leakyabstractions.com/docs/advanced\n[GUIDE_BASIC]:                  https://result.leakyabstractions.com/docs/basic\n[GUIDE_BOOK]:                   https://leanpub.com/result/\n[GUIDE_HOME]:                   https://result.leakyabstractions.com/\n[GUIDE_START]:                  https://result.leakyabstractions.com/docs/start\n[GUILLERMO]:                    https://guillermo.dev/\n[GUILLERMO_IMAGE]:              https://guillermo.dev/assets/images/thumb.png\n[JAVADOC]:                      https://javadoc.io/doc/com.leakyabstractions/result/\n[LOGO_DARK]:                    docs/result-logo.dark.svg#gh-dark-mode-only\n[LOGO_LIGHT]:                   docs/result-logo.svg#gh-light-mode-only\n[PRAGVER]:                      https://pragver.github.io/\n[QUALITY_GATE]:                 https://sonarcloud.io/dashboard?id=LeakyAbstractions_result\n[SUPPORT]:                      https://github.com/LeakyAbstractions/.github/blob/main/SUPPORT.md\n[USING_EXCEPTIONS]:             docs/using-exceptions.png\n[USING_RESULTS]:                docs/using-results.png\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fleakyabstractions%2Fresult","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fleakyabstractions%2Fresult","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fleakyabstractions%2Fresult/lists"}