{"id":18981422,"url":"https://github.com/awncorp/data-object-try","last_synced_at":"2025-08-02T22:04:35.689Z","repository":{"id":77256518,"uuid":"300957217","full_name":"awncorp/data-object-try","owner":"awncorp","description":"Try Class for Perl 5","archived":false,"fork":false,"pushed_at":"2020-10-03T20:35:40.000Z","size":29,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-02-21T09:19:29.515Z","etag":null,"topics":["object-oriented","perl","perl5"],"latest_commit_sha":null,"homepage":null,"language":"Perl","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/awncorp.png","metadata":{"files":{"readme":"README","changelog":"CHANGES","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","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-10-03T19:06:08.000Z","updated_at":"2022-07-24T20:58:28.000Z","dependencies_parsed_at":"2023-02-27T09:31:21.390Z","dependency_job_id":null,"html_url":"https://github.com/awncorp/data-object-try","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/awncorp/data-object-try","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/awncorp%2Fdata-object-try","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/awncorp%2Fdata-object-try/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/awncorp%2Fdata-object-try/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/awncorp%2Fdata-object-try/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/awncorp","download_url":"https://codeload.github.com/awncorp/data-object-try/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/awncorp%2Fdata-object-try/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":268464281,"owners_count":24254196,"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-08-02T02:00:12.353Z","response_time":74,"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":["object-oriented","perl","perl5"],"created_at":"2024-11-08T16:09:48.470Z","updated_at":"2025-08-02T22:04:35.603Z","avatar_url":"https://github.com/awncorp.png","language":"Perl","funding_links":[],"categories":[],"sub_categories":[],"readme":"NAME\n\n    Data::Object::Try\n\nABSTRACT\n\n    Try Class for Perl 5\n\nSYNOPSIS\n\n      use strict;\n      use warnings;\n      use routines;\n    \n      use Data::Object::Try;\n    \n      my $try = Data::Object::Try-\u003enew;\n    \n      $try-\u003ecall(fun (@args) {\n        # try something\n    \n        return time;\n      });\n    \n      $try-\u003ecatch('Example::Exception', fun ($caught) {\n        # caught an exception\n    \n        return;\n      });\n    \n      $try-\u003edefault(fun ($caught) {\n        # catch the uncaught\n    \n        return;\n      });\n    \n      $try-\u003efinally(fun (@args) {\n        # always run after try/catch\n    \n        return;\n      });\n    \n      my @args;\n    \n      my $result = $try-\u003eresult(@args);\n\nDESCRIPTION\n\n    This package provides an object-oriented interface for performing\n    complex try/catch operations.\n\nATTRIBUTES\n\n    This package has the following attributes:\n\n arguments\n\n      arguments(ArrayRef)\n\n    This attribute is read-only, accepts (ArrayRef) values, and is\n    optional.\n\n invocant\n\n      invocant(Object)\n\n    This attribute is read-only, accepts (Object) values, and is optional.\n\n on_catch\n\n      on_catch(ArrayRef[CodeRef])\n\n    This attribute is read-write, accepts (ArrayRef[CodeRef]) values, and\n    is optional.\n\n on_default\n\n      on_default(CodeRef)\n\n    This attribute is read-write, accepts (CodeRef) values, and is\n    optional.\n\n on_finally\n\n      on_finally(CodeRef)\n\n    This attribute is read-write, accepts (CodeRef) values, and is\n    optional.\n\n on_try\n\n      on_try(CodeRef)\n\n    This attribute is read-write, accepts (CodeRef) values, and is\n    optional.\n\nMETHODS\n\n    This package implements the following methods:\n\n call\n\n      call(Str | CodeRef $arg) : Object\n\n    The call method takes a method name or coderef, registers it as the\n    tryable routine, and returns the object. When invoked, the callback\n    will received an invocant if one was provided to the constructor, the\n    default arguments if any were provided to the constructor, and whatever\n    arguments were provided by the invocant.\n\n    call example #1\n\n        my $try = Data::Object::Try-\u003enew;\n      \n        $try-\u003ecall(fun (@args) {\n      \n          return [@args];\n        });\n\n callback\n\n      callback(Str | CodeRef $arg) : CodeRef\n\n    The callback method takes a method name or coderef, and returns a\n    coderef for registration. If a coderef is provided this method is\n    mostly a passthrough.\n\n    callback example #1\n\n        my $try = Data::Object::Try-\u003enew;\n      \n        $try-\u003ecallback(fun (@args) {\n      \n          return [@args];\n        });\n\n    callback example #2\n\n        package Example;\n      \n        use Moo;\n      \n        fun test(@args) {\n      \n          return [@args];\n        }\n      \n        package main;\n      \n        my $try = Data::Object::Try-\u003enew(\n          invocant =\u003e Example-\u003enew\n        );\n      \n        $try-\u003ecallback('test');\n\n catch\n\n      catch(Str $isa, Str | CodeRef $arg) : Any\n\n    The catch method takes a package or ref name, and when triggered checks\n    whether the captured exception is of the type specified and if so\n    executes the given callback.\n\n    catch example #1\n\n        my $try = Data::Object::Try-\u003enew;\n      \n        $try-\u003ecall(fun (@args) {\n      \n          die $try;\n        });\n      \n        $try-\u003ecatch('Data::Object::Try', fun (@args) {\n      \n          return [@args];\n        });\n\n default\n\n      default(Str | CodeRef $arg) : Object\n\n    The default method takes a method name or coderef and is triggered if\n    no catch conditions match the exception thrown.\n\n    default example #1\n\n        my $try = Data::Object::Try-\u003enew;\n      \n        $try-\u003ecall(fun (@args) {\n      \n          die $try;\n        });\n      \n        $try-\u003edefault(fun (@args) {\n      \n          return [@args];\n        });\n\n execute\n\n      execute(CodeRef $arg, Any @args) : Any\n\n    The execute method takes a coderef and executes it with any given\n    arguments. When invoked, the callback will received an invocant if one\n    was provided to the constructor, the default arguments if any were\n    provided to the constructor, and whatever arguments were passed\n    directly to this method.\n\n    execute example #1\n\n        my $try = Data::Object::Try-\u003enew(\n          invocant =\u003e Example-\u003enew,\n          arguments =\u003e [1,2,3]\n        );\n      \n        $try-\u003eexecute(fun (@args) {\n      \n          return [@args];\n        });\n\n finally\n\n      finally(Str | CodeRef $arg) : Object\n\n    The finally method takes a package or ref name and always executes the\n    callback after a try/catch operation. The return value is ignored. When\n    invoked, the callback will received an invocant if one was provided to\n    the constructor, the default arguments if any were provided to the\n    constructor, and whatever arguments were provided by the invocant.\n\n    finally example #1\n\n        my $try = Data::Object::Try-\u003enew(\n          invocant =\u003e Example-\u003enew,\n          arguments =\u003e [1,2,3]\n        );\n      \n        $try-\u003ecall(fun (@args) {\n      \n          return $try;\n        });\n      \n        $try-\u003efinally(fun (@args) {\n      \n          $try-\u003e{'$finally'} = [@args];\n        });\n\n maybe\n\n      maybe() : Object\n\n    The maybe method registers a default catch condition that returns\n    falsy, i.e. an empty string, if an exception is encountered.\n\n    maybe example #1\n\n        my $try = Data::Object::Try-\u003enew;\n      \n        $try-\u003ecall(fun (@args) {\n      \n          die $try;\n        });\n      \n        $try-\u003emaybe;\n\n no_catch\n\n      no_catch() : Object\n\n    The no_catch method removes any configured catch conditions and returns\n    the object.\n\n    no_catch example #1\n\n        my $try = Data::Object::Try-\u003enew;\n      \n        $try-\u003ecall(fun (@args) {\n      \n          die $try;\n        });\n      \n        $try-\u003ecatch('Data::Object::Try', fun (@args) {\n      \n          return [@args];\n        });\n      \n        $try-\u003eno_catch;\n\n no_default\n\n      no_default() : Object\n\n    The no_default method removes any configured default condition and\n    returns the object.\n\n    no_default example #1\n\n        my $try = Data::Object::Try-\u003enew;\n      \n        $try-\u003ecall(fun (@args) {\n      \n          die $try;\n        });\n      \n        $try-\u003edefault(fun (@args) {\n      \n          return [@args];\n        });\n      \n        $try-\u003eno_default;\n\n no_finally\n\n      no_finally() : Object\n\n    The no_finally method removes any configured finally condition and\n    returns the object.\n\n    no_finally example #1\n\n        my $try = Data::Object::Try-\u003enew(\n          invocant =\u003e Example-\u003enew,\n          arguments =\u003e [1,2,3]\n        );\n      \n        $try-\u003ecall(fun (@args) {\n      \n          return $try;\n        });\n      \n        $try-\u003efinally(fun (@args) {\n      \n          $try-\u003e{'$finally'} = [@args];\n        });\n      \n        $try-\u003eno_finally;\n\n no_try\n\n      no_try() : Object\n\n    The no_try method removes any configured try operation and returns the\n    object.\n\n    no_try example #1\n\n        my $try = Data::Object::Try-\u003enew;\n      \n        $try-\u003ecall(fun (@args) {\n      \n          return [@args];\n        });\n      \n        $try-\u003eno_try;\n\n result\n\n      result(Any @args) : Any\n\n    The result method executes the try/catch/default/finally logic and\n    returns either 1) the return value from the successfully tried\n    operation 2) the return value from the successfully matched catch\n    condition if an exception was thrown 3) the return value from the\n    default catch condition if an exception was thrown and no catch\n    condition matched. When invoked, the try and finally callbacks will\n    received an invocant if one was provided to the constructor, the\n    default arguments if any were provided to the constructor, and whatever\n    arguments were passed directly to this method.\n\n    result example #1\n\n        my $try = Data::Object::Try-\u003enew;\n      \n        $try-\u003ecall(fun (@args) {\n      \n          return [@args];\n        });\n      \n        $try-\u003eresult;\n\n    result example #2\n\n        my $try = Data::Object::Try-\u003enew;\n      \n        $try-\u003ecall(fun (@args) {\n      \n          return [@args];\n        });\n      \n        $try-\u003eresult(1..5);\n\nAUTHOR\n\n    Al Newkirk, awncorp@cpan.org\n\nLICENSE\n\n    Copyright (C) 2011-2019, Al Newkirk, et al.\n\n    This is free software; you can redistribute it and/or modify it under\n    the terms of the The Apache License, Version 2.0, as elucidated in the\n    \"license file\"\n    \u003chttps://github.com/iamalnewkirk/data-object-try/blob/master/LICENSE\u003e.\n\nPROJECT\n\n    Wiki \u003chttps://github.com/iamalnewkirk/data-object-try/wiki\u003e\n\n    Project \u003chttps://github.com/iamalnewkirk/data-object-try\u003e\n\n    Initiatives \u003chttps://github.com/iamalnewkirk/data-object-try/projects\u003e\n\n    Milestones \u003chttps://github.com/iamalnewkirk/data-object-try/milestones\u003e\n\n    Contributing\n    \u003chttps://github.com/iamalnewkirk/data-object-try/blob/master/CONTRIBUTE.md\u003e\n\n    Issues \u003chttps://github.com/iamalnewkirk/data-object-try/issues\u003e\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fawncorp%2Fdata-object-try","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fawncorp%2Fdata-object-try","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fawncorp%2Fdata-object-try/lists"}