{"id":18501669,"url":"https://github.com/vvelox/error-helper","last_synced_at":"2025-05-14T07:32:19.799Z","repository":{"id":210466023,"uuid":"726611852","full_name":"VVelox/Error-Helper","owner":"VVelox","description":"Provides some handy error related methods","archived":false,"fork":false,"pushed_at":"2023-12-10T21:44:48.000Z","size":24,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-17T01:42:30.859Z","etag":null,"topics":["error-handling","perl"],"latest_commit_sha":null,"homepage":"https://metacpan.org/dist/Error-Helper","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/VVelox.png","metadata":{"files":{"readme":"README.md","changelog":"Changes","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":"2023-12-02T21:44:08.000Z","updated_at":"2023-12-04T02:44:09.000Z","dependencies_parsed_at":"2023-12-10T22:29:43.865Z","dependency_job_id":"23e4fbb0-de64-47c4-b75d-8c40c3961d90","html_url":"https://github.com/VVelox/Error-Helper","commit_stats":{"total_commits":20,"total_committers":1,"mean_commits":20.0,"dds":0.0,"last_synced_commit":"bb1fc6f0d6b389434071eae9388595a4694976ad"},"previous_names":["vvelox/error-helper"],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/VVelox%2FError-Helper","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/VVelox%2FError-Helper/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/VVelox%2FError-Helper/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/VVelox%2FError-Helper/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/VVelox","download_url":"https://codeload.github.com/VVelox/Error-Helper/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254095240,"owners_count":22013731,"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":["error-handling","perl"],"created_at":"2024-11-06T13:54:32.570Z","updated_at":"2025-05-14T07:32:19.767Z","avatar_url":"https://github.com/VVelox.png","language":"Perl","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Error::Helper Synopsis\n\nThis module allows one to use it as a base for adding various error\nhandling methods to their module. Error checking can be done in two\nmethods, either calling one of error checking functions and seeing if\nit is present or setting that error code/flag to be fatal and\ncollecting failures via eval and then when processing $@, then check\nthe error code/flag.\n\nThere are five required variables in the blessed hash object.\n\n- $self-\u003e{error} :: This contains the current error code.\n  - Type :: int or undef\n\n- $self-\u003e{errorFilename} :: File from which $self-\u003ewarn was called.\n  - Type :: string or undef\n\n- $self-\u003e{errorLine} :: Line from which $self-\u003ewarn was called.\n  - Type :: int or undef\n\n- $self-\u003e{errorString} :: This contains a description of the current error.\n  - Type :: string or undef\n\n- $self-\u003e{perror} :: This is set to true is a permanent error is\n  present. If note, it needs set to false.\n  - Type :: Perl boolean\n\nThe following are optional.\n\n- $self-\u003e{errorExtra} :: This is a hash reserved for any additional Error::Helper items.\n\n- $self-\u003e{errorExtra}{all_errors_fatal} :: If true, this will die when\n            $self-\u003ewarn is called instead of printing the error to\n            STDERR. This is for if you want to use it eval for\n            capturing errors and this module more for handling\n            grabbing error specifics, such as dieing and additional\n            code based on the return of $self-\u003eerrorFlag.\n\t\t- Type :: Perl boolean\n\t\t- Default :: undef\n\n- $self-\u003e{errorExtra}{fatal_errors} :: This is a hash in which the\n            keys are errors codes that are fatal. When $self-\u003ewarn is\n            called it will check if the error code is fatal or\n            not. $self-\u003e{errorExtra}{fatal_errors}{33}=\u003e1 would be\n            fatal, but $self-\u003e{errorExtra}{fatal_errors}{33}=\u003e0 would\n            now.\n\n- $self-\u003e{errorExtra}{flags} :: This hash contains error integer to\n            flag mapping. The keys are the error integer and the value\n            is the flag. For any unmatched error integers, 'other' is returned.\n\n- $self-\u003e{errorExtra}{fatal_flags} :: This is a hash in which the keys\n            are error flags that are fatal. When $self-\u003ewarn is called\n            it will check if the flag for the error code is fatal or\n            not. For the flag foo\n            $self-\u003e{errorExtra}{fatal_flags}{foo}=\u003e1 would be fatal,\n            but $self-\u003e{errorExtra}{fatal_flags}{foo}=\u003e0 would now.\n\n- $self-\u003e{errorExtra}{perror_not_fatal} :: Controls if $self-\u003e{perror}\n  is fatal or not.\n  - Type :: Perl boolean\n  - Default :: undef\n\n\nBelow is a example script showing it all being used.\n\n```perl\n#!/usr/bin/env perl\nuse warnings;\nuse strict;\n\n{\n\tpackage Foo;\n\tuse base 'Error::Helper';\n\n\tsub new {\n\t\tmy $arg = $_[1];\n\n\t\tmy $self = {\n\t\t\tperror        =\u003e undef,\n\t\t\terror         =\u003e undef,\n\t\t\terrorLine     =\u003e undef,\n\t\t\terrorFilename =\u003e undef,\n\t\t\terrorString   =\u003e \"\",\n\t\t\terrorExtra    =\u003e {\n\t\t\t\tall_errors_fatal =\u003e 0,\n\t\t\t\tflags            =\u003e {\n\t\t\t\t\t1 =\u003e 'UndefArg',\n\t\t\t\t\t2 =\u003e 'test',\n\t\t\t\t\t3 =\u003e 'derp',\n\t\t\t\t},\n\t\t\t\tfatal_flags =\u003e {\n\t\t\t\t\tderp =\u003e 1,\n\t\t\t\t},\n\t\t\t\tperror_not_fatal =\u003e 0,\n\t\t\t},\n\t\t};\n\t\tbless $self;\n\n\t\t#error if $arg is set to \"test\"\n\t\tif ( defined($arg)\n\t\t\t\u0026\u0026 $arg eq \"test\" )\n\t\t{\n\t\t\t$self-\u003e{perror}      = 1;\n\t\t\t$self-\u003e{error}       = 2;\n\t\t\t$self-\u003e{errorString} = 'A value of \"test\" has been set';\n\t\t\t$self-\u003ewarn;\n\t\t\treturn $self;\n\t\t}\n\n\t\treturn $self;\n\t} ## end sub new\n\n\tsub foo {\n\t\tmy $self = $_[0];\n\t\tmy $a    = $_[1];\n\n\t\tif ( !$self-\u003eerrorblank ) {\n\t\t\treturn undef;\n\t\t}\n\n\t\tif ( !defined($a) ) {\n\t\t\t$self-\u003e{error}       = 1;\n\t\t\t$self-\u003e{errorString} = 'No value specified';\n\t\t\t$self-\u003ewarn;\n\t\t\treturn undef;\n\t\t}\n\n\t\tif ( $a eq 'derp' ) {\n\t\t\t$self-\u003e{error}       = 3;\n\t\t\t$self-\u003e{errorString} = 'foo was called with a value of derp';\n\t\t\t$self-\u003ewarn;\n\t\t}\n\n\t\treturn 1;\n\t} ## end sub foo\n}\n\nmy $foo_obj = Foo-\u003enew( $ARGV[0] );\nif ( $foo_obj-\u003eerror ) {\n\twarn( 'error:' . $foo_obj-\u003eerror . ': ' . $foo_obj-\u003eerrorString );\n\texit $foo_obj-\u003eerror;\n}\n\neval { $foo_obj-\u003efoo( $ARGV[1] ); };\nif ($@) {\n\t# do something...\n\twarn( '$foo_obj-\u003efoo( $ARGV[1] ) errored.... ' . $@ );\n\tif ( $foo_obj-\u003eerrorFlag eq 'derp' ) {\n\t\twarn('error flag derp found... calling again with a value of default');\n\t\t$foo_obj-\u003efoo('default');\n\t}\n} elsif ( $foo_obj-\u003eerror ) {\n\t# do something...\n\t$foo_obj-\u003ewarnString('non-fatal error when calling foo');\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvvelox%2Ferror-helper","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvvelox%2Ferror-helper","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvvelox%2Ferror-helper/lists"}