{"id":15510650,"url":"https://github.com/dalen/puppet-trycatch","last_synced_at":"2025-04-23T03:05:04.658Z","repository":{"id":57665911,"uuid":"43690158","full_name":"dalen/puppet-trycatch","owner":"dalen","description":null,"archived":false,"fork":false,"pushed_at":"2015-10-05T16:37:57.000Z","size":124,"stargazers_count":8,"open_issues_count":1,"forks_count":2,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-23T03:04:59.292Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dalen.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-10-05T14:41:54.000Z","updated_at":"2018-05-15T07:47:08.000Z","dependencies_parsed_at":"2022-09-14T13:01:47.619Z","dependency_job_id":null,"html_url":"https://github.com/dalen/puppet-trycatch","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/dalen%2Fpuppet-trycatch","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dalen%2Fpuppet-trycatch/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dalen%2Fpuppet-trycatch/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dalen%2Fpuppet-trycatch/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dalen","download_url":"https://codeload.github.com/dalen/puppet-trycatch/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250360479,"owners_count":21417721,"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-02T09:50:17.486Z","updated_at":"2025-04-23T03:05:04.642Z","avatar_url":"https://github.com/dalen.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# trycatch\n\nThis is a simple Puppet module that adds the functions `try` and `catch`.\nThey can be used to catch an exception raised in the block passed to `try`.\n\nThis module uses the V4 function API, so you need Puppet 4.x to use it or\nPuppet 3.7.x with the future parser.\n\n## Example\n\n```puppet\n$ret = try() || {\n  assert_type('String', 1)\n  notice('This code is never reached')\n  'return value from try'\n}.catch |$exception| {\n  notice($exception['class'])\n  notice($exception['message'])\n  'return value from catch'\n}\nnotice($ret)\n```\n\nOutput:\n\n```\nNotice: Scope(Class[main]): Puppet::PreformattedError\nNotice: Scope(Class[main]): Evaluation Error: Error while evaluating a Function Call, assert_type(): Expected type String does not match actual: Integer at /Users/dalen/src/puppet-trycatch/test.pp:2:3\nNotice: Scope(Class[main]): return value from catch\nNotice: Compiled catalog for river.local in environment production in 0.28 seconds\nNotice: Applied catalog in 0.01 seconds\n```\n\n### Only catch certain exceptions\n\n```\ntry() || {\n  assert_type('String', 1)\n}.catch('ArgumentError', 'RuntimeError') |$exception| {\n  notice(\"Caught ${$exception['class']}\")\n}\n```\n\nOutput:\n\n```\nError: Evaluation Error: Error while evaluating a Function Call, assert_type(): Expected type String does not match actual: Integer at /Users/dalen/src/puppet-trycatch/test.pp:2:3 on node river.local\n```\n\nNote that this doesn't take exception subclasses into account. It only checks\nif the class names match exactly.\n\n## Note that this is a hack, use accordingly\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdalen%2Fpuppet-trycatch","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdalen%2Fpuppet-trycatch","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdalen%2Fpuppet-trycatch/lists"}