{"id":24539304,"url":"https://github.com/nathanpb/safer","last_synced_at":"2025-07-31T22:02:33.130Z","repository":{"id":103211963,"uuid":"292959664","full_name":"NathanPB/Safer","owner":"NathanPB","description":"JVM Error Recovering library for stupid devs (like me) who can't write safe code","archived":false,"fork":false,"pushed_at":"2020-09-14T06:53:54.000Z","size":70,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-16T03:41:29.973Z","etag":null,"topics":["error-handling","jvm"],"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/NathanPB.png","metadata":{"files":{"readme":"README.md","changelog":null,"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}},"created_at":"2020-09-04T22:38:05.000Z","updated_at":"2020-09-14T06:53:56.000Z","dependencies_parsed_at":"2023-06-29T00:01:20.826Z","dependency_job_id":null,"html_url":"https://github.com/NathanPB/Safer","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/NathanPB/Safer","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NathanPB%2FSafer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NathanPB%2FSafer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NathanPB%2FSafer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NathanPB%2FSafer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/NathanPB","download_url":"https://codeload.github.com/NathanPB/Safer/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NathanPB%2FSafer/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":268125622,"owners_count":24200284,"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","status":"online","status_checked_at":"2025-07-31T02:00:08.723Z","response_time":66,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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","jvm"],"created_at":"2025-01-22T16:16:13.348Z","updated_at":"2025-07-31T22:02:33.121Z","avatar_url":"https://github.com/NathanPB.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"![](https://github.com/NathanPB/Safer/workflows/Java%20CI%20with%20Gradle/badge.svg)\n\nSafer is a little JVM error handling library made to catch errors in critical points of the program execution when they are not expected to happen.\n\n# Whats the point\nSafer is designed to prevent fatal errors in an application when you don't expect an Exception to be thrown.\nIt's designed to be used with [Mixin](https://github.com/SpongePowered/Mixin), a framework to make runtime bytecode injectons. Since it requires a lot of unsafe class casts, the Type Inference is damaged and a lot of different exceptions may appear and set the production on fire.\n\n\nWhen to use Safer\n- When you are implementing a critical code fragment\n- When you are injecting a code fragment into another class' bytecode\n\nWhen **not** to use Safer\n- **When you are sure something will go wrong:** Safer is meant to be used as **the last resource** of recovering from a fatal error. If you know an error will be throw, ``try/catch`` it.\n\n# Installation\nbuild.gradle\n```groovy\n    repositories {\n        ...\n        maven { url 'https://jitpack.io' }\n    }\n```\n```groovy\n    dependencies {\n        implementation 'com.github.NathanPB:Safer:VERSION'\n    }\n```\n\nSee the versions [in the releases page](https://github.com/NathanPB/Safer/releases)\n\n# How to use\n```java\npublic void unsafeCodeFragment() {\n    Safer.run(() -\u003e {\n      // Critical and unsafe code fragment\n    })\n}\n```\n\n```java\npublic String unsafeCodeFragment() {\n    return Safer.run(\"default value to return if something goes wrong\", () -\u003e {\n      // Critical and unsafe code fragment\n    })\n}\n```\n\nIf your default value is something a bit expensive, do it lazy\n```java\npublic String unsafeCodeFragment() {\n    return Safer.runLazy(() -\u003e factorial(12), () -\u003e {\n      // Critical and unsafe code fragment\n    })\n}\n```\n\nFor more examples check [the tests files](https://github.com/NathanPB/Safer/tree/master/src/test/java)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnathanpb%2Fsafer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnathanpb%2Fsafer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnathanpb%2Fsafer/lists"}