{"id":17041670,"url":"https://github.com/xlab/catcher","last_synced_at":"2025-04-12T14:33:17.161Z","repository":{"id":239784708,"uuid":"800565446","full_name":"xlab/catcher","owner":"xlab","description":"When S hits F, your app will be safe from panics.","archived":false,"fork":false,"pushed_at":"2024-05-14T17:06:55.000Z","size":17,"stargazers_count":3,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-26T09:11:11.403Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Go","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/xlab.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":"2024-05-14T15:20:12.000Z","updated_at":"2024-05-15T13:03:09.000Z","dependencies_parsed_at":null,"dependency_job_id":"7e264247-76d6-45e2-8857-8e123fc786af","html_url":"https://github.com/xlab/catcher","commit_stats":null,"previous_names":["xlab/catcher"],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xlab%2Fcatcher","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xlab%2Fcatcher/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xlab%2Fcatcher/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xlab%2Fcatcher/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/xlab","download_url":"https://codeload.github.com/xlab/catcher/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248581361,"owners_count":21128155,"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":[],"created_at":"2024-10-14T09:13:09.773Z","updated_at":"2025-04-12T14:33:17.141Z","avatar_url":"https://github.com/xlab.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"Catcher [![GoDoc](https://godoc.org/github.com/xlab/catcher?status.svg)](https://godoc.org/github.com/xlab/catcher)\n=======\n\nA package to gracefully handle crap software. From the creator of [closer](https://github.com/xlab/closer).\n\nSee [example](example/main.go).\n\n```go\nfunc main() {\n    defer catcher.Catch(\n        catcher.RecvWrite(os.Stderr, true),\n    )\n\n    if err := safeCall(); err != nil {\n        log.Println(\"[ERR] safeCall failed with:\", err)\n    }\n\n    suspiciousFunc()\n}\n\n// suspiciousFunc will definitely panic. Usually this kind of functions\n// panic only on Saturdays or holidays, but for test simplicity this one\n// will panic 100% of the time.\nfunc suspiciousFunc() {\n    panic(\"sorry pls\")\n}\n```\n\nResult:\n\n```\n$ go run main.go\n\ncaught error: catch me\nmain.go:21: [ERR] safeCall failed with: catch me\ncaught panic: sorry pls from suspiciousFunc\n\nstacktrace: panic\n/usr/local/go/src/runtime/asm_amd64.s:479 (0x4f4cc)\n    call32: CALLFN(·call32, 32)\n/usr/local/go/src/runtime/panic.go:458 (0x26fc3)\n    gopanic: reflectcall(nil, unsafe.Pointer(d.fn), deferArgs(d), uint32(d.siz), uint32(d.siz))\n/Users/xlab/Documents/dev/go/src/github.com/xlab/catcher/example/main.go:28 (0x22fd)\n    suspiciousFunc: panic(\"sorry\")\n/Users/xlab/Documents/dev/go/src/github.com/xlab/catcher/example/main.go:24 (0x2186)\n    main: suspiciousFunc()\n/usr/local/go/src/runtime/proc.go:183 (0x28c74)\n    main: main_main()\n/usr/local/go/src/runtime/asm_amd64.s:2059 (0x51f31)\n    goexit: BYTE    $0x90   // NOP\n```\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxlab%2Fcatcher","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fxlab%2Fcatcher","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxlab%2Fcatcher/lists"}