From 8c78834b61f2829d71c068b1b183dffdd0a3198b Mon Sep 17 00:00:00 2001 From: swag Date: Fri, 22 Jul 2022 13:10:18 -0400 Subject: [PATCH] Implement uh... try/catch sorta --- guestbook-ng.pl | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/guestbook-ng.pl b/guestbook-ng.pl index e861be0..db54bd0 100755 --- a/guestbook-ng.pl +++ b/guestbook-ng.pl @@ -94,20 +94,26 @@ any [qw{GET POST}], '/sign' => sub ($c) { elsif (app->mode() eq 'production' && -s '.tom.url') { my ($new_message_id, $url_file, $url, $webhook); - $new_message_id = $c->message->get_last_message_id(); + eval { + $new_message_id = $c->message->get_last_message_id(); - open($url_file, '.tom.url') || die "$@"; - chomp($url = <$url_file>); + open($url_file, '.tom.url'); + chomp($url = <$url_file>); - $webhook = WebService::Discord::Webhook->new( - url => $url, - verify_SSL => 1 - ); + $webhook = WebService::Discord::Webhook->new( + url => $url, + verify_SSL => 1 + ); - $webhook->execute( - 'content', - "https://guestbook.swagg.net/message/$new_message_id" - ); + $webhook->execute( + 'content', + "https://guestbook.swagg.net/message/$new_message_id" + ); + } or do { + $@ //= 'unknown error'; + + say "WEBHOOK URL $url FAILED: $@"; + } } return $c->redirect_to(page => {page => 'view'});