Skip to content

Commit 2ec984a

Browse files
committed
Added: Datahub::Factory::FixFileNotFound error.
1 parent 911b9db commit 2ec984a

File tree

4 files changed

+23
-0
lines changed

4 files changed

+23
-0
lines changed

Changes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ Revision history for Datahub-Factory
22

33
{{$NEXT}}
44

5+
- Added: Datahub::Factory::FixFileNotFound error.
56
- Added: Datahub::Factory::InvalidCondition error.
67
- Fixed: fixes #62 fixer Fix throws an error file_name is undefined
78
- Added: fixes #61 break after finite number of records in transport.

lib/Datahub/Factory/Command/transport.pm

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,12 @@ sub execute {
150150
$logger->fatal($error);
151151
exit 1;
152152
}
153+
elsif (is_instance $_, 'Datahub::Factory::FixFileNotFound') {
154+
# Throw a fatal error if the pipeline configuration was invalid
155+
$self->error($msg);
156+
$logger->fatal($error);
157+
exit 1;
158+
}
153159
elsif (is_instance $_, 'Datahub::Factory::ModuleNotFound') {
154160
# Throw a fatal error if we couldn't load a fix module
155161
$logger->fatal($error);

lib/Datahub/Factory/Error.pm

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,15 @@ use namespace::clean;
4343

4444
extends 'Datahub::Factory::Error';
4545

46+
package Datahub::Factory::FixFileNotFound;
47+
48+
use Datahub::Factory::Sane;
49+
50+
use Moo;
51+
use namespace::clean;
52+
53+
extends 'Datahub::Factory::Error';
54+
4655
package Datahub::Factory::ModuleNotFound;
4756

4857
use Datahub::Factory::Sane;

lib/Datahub/Factory/Fixer/Fix.pm

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ our $VERSION = '1.73';
66

77
use Moo;
88
use Catmandu;
9+
use Datahub::Factory;
910
use namespace::clean;
1011

1112
has file_name => (is => 'ro', required => 1, isa => sub {
@@ -14,6 +15,12 @@ has file_name => (is => 'ro', required => 1, isa => sub {
1415
message => 'Required argument "file_name" undefined'
1516
);
1617
}
18+
19+
if (! -e $_[0]) {
20+
Datahub::Factory::FixFileNotFound->throw(
21+
message => sprintf('Fix file %s could not be found on the filesystem.', $_[0])
22+
);
23+
}
1724
});
1825

1926
with 'Datahub::Factory::Fixer';

0 commit comments

Comments
 (0)