From c0a59a633485eba46d21608a1d245ed75bd0661d Mon Sep 17 00:00:00 2001 From: Stefan Schantl Date: Wed, 25 Nov 2015 15:38:01 +0100 Subject: [PATCH] Adjust error messages in case of failure. Remove the new line prefixes from various error messages. The logger automatically will take care of this. Signed-off-by: Stefan Schantl --- guardian | 8 ++++---- modules/Base.pm | 2 +- modules/Config.pm | 6 +++--- modules/Socket.pm | 6 +++--- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/guardian b/guardian index da9665c..f480c11 100644 --- a/guardian +++ b/guardian @@ -82,7 +82,7 @@ my %monitored_files :shared = (); # Create the main queue. It is used to store and process all events which are # reported and enqueued by the worker threads. -my $queue :shared = new Thread::Queue or die "Could not create new, empty queue. $!\n";; +my $queue :shared = new Thread::Queue or die "Could not create new, empty queue. $!";; # Array to store all currently running worker objects. # (Does not include the socket thread) @@ -160,10 +160,10 @@ sub Worker ($) { $SIG{'KILL'} = sub { threads->exit(); }; # Create inotify watcher. - my $watcher = new Linux::Inotify2 or die "Could not use inotify. $!\n"; + my $watcher = new Linux::Inotify2 or die "Could not use inotify. $!"; # Monitor the specified file. - $watcher->watch("$file", IN_MODIFY) or die "Could not monitor $file. $!\n"; + $watcher->watch("$file", IN_MODIFY) or die "Could not monitor $file. $!"; # Switch watcher into non-blocking mode. $watcher->blocking(0); @@ -182,7 +182,7 @@ sub Worker ($) { my $fileposition = $monitored_files{$file}; # Open the file. - open (FILE, $file) or die "Could not open $file. $!\n"; + open (FILE, $file) or die "Could not open $file. $!"; # Seek to the last known position. seek (FILE, $fileposition, 0); diff --git a/modules/Base.pm b/modules/Base.pm index e4ff8a0..0e43823 100644 --- a/modules/Base.pm +++ b/modules/Base.pm @@ -20,7 +20,7 @@ sub InitFileposition ($) { my $file = $_[0]; # Open the file. - open(FILE, $file) or die "Could not open $file. $!\n"; + open(FILE, $file) or die "Could not open $file. $!"; # Just seek to the end of the file (EOF). seek(FILE, 0, 2); diff --git a/modules/Config.pm b/modules/Config.pm index 9f2fc55..9a8e1fd 100644 --- a/modules/Config.pm +++ b/modules/Config.pm @@ -56,7 +56,7 @@ sub UseConfig ($) { # If an error message is returned, exit and print the error message. } else { - die "Invalid configuration: $error\n"; + die "Invalid configuration: $error"; } } @@ -74,11 +74,11 @@ sub ReadConfig ($) { # Check if the configfile exists and is read-able. unless (-r "$file") { - die "The given configfile ($file) does not exist, or is not read-able: $!\n"; + die "The given configfile ($file) does not exist, or is not read-able: $!"; } # Open the config file and read-in all configuration options and values. - open(CONF, "$file") or die "Could not open $file: $!\n"; + open(CONF, "$file") or die "Could not open $file: $!"; # Process line by line. while (my $line = ) { diff --git a/modules/Socket.pm b/modules/Socket.pm index 5e5a998..3b758dc 100644 --- a/modules/Socket.pm +++ b/modules/Socket.pm @@ -33,13 +33,13 @@ sub Server () { # If the path for the socketfile does not exist, try to # create it. unless (-d "$socketpath") { - mkdir("$socketpath") or die "Could not create $socketpath: $!\n"; + mkdir("$socketpath") or die "Could not create $socketpath: $!"; } # Delete an existing socket file. if (-e "$socketfile") { unlink $socketfile - or die "Could not release existing socket file: $!\n"; + or die "Could not release existing socket file: $!"; } # Create a new UNIX socket. @@ -47,7 +47,7 @@ sub Server () { Local => $socketfile, Listen => SOMAXCONN, Type => SOCK_STREAM, - ) or die "Could not create socket: $!\n"; + ) or die "Could not create socket: $!"; # Return the server object. return $server; -- 2.39.2