Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision a6291ceb

Von Jan Büren vor mehr als 3 Jahren hinzugefügt

  • ID a6291ceb5b16c6faf4e24c6d1a5516f06df58e22
  • Vorgänger 0da98971
  • Nachfolger fb35d214

CTR: Benutzereingabe in data mit Try::Tiny auffangen

Sinnvolle Fehlermeldung in einem Satz zurückgeben und
danach den kompletten Trace.

Unterschiede anzeigen:

SL/BackgroundJob/ConvertTimeRecordings.pm
8 8
use SL::DB::TimeRecording;
9 9

  
10 10
use SL::Locale::String qw(t8);
11

  
11 12
use DateTime;
13
use Try::Tiny;
12 14

  
13 15
sub create_job {
14 16
  $_[0]->create_standard_job('7 3 1 * *'); # every first day of month at 03:07
......
31 33
  # from/to date from data. Defaults to begining and end of last month.
32 34
  my $from_date;
33 35
  my $to_date;
34
  $from_date   = DateTime->from_kivitendo($data->{from_date}) if $data->{from_date};
35
  $to_date     = DateTime->from_kivitendo($data->{to_date})   if $data->{to_date};
36
  # handle errors with a catch handler
37
  try {
38
    $from_date   = DateTime->from_kivitendo($data->{from_date}) if $data->{from_date};
39
    $to_date     = DateTime->from_kivitendo($data->{to_date})   if $data->{to_date};
40
  } catch {
41
    die "Cannot convert date from string $data->{from_date} $data->{to_date}\n Details :\n $_"; # not $@
42
  };
36 43
  $from_date ||= DateTime->new( day => 1,    month => DateTime->today_local->month, year => DateTime->today_local->year)->subtract(months => 1);
37 44
  $to_date   ||= DateTime->last_day_of_month(month => DateTime->today_local->month, year => DateTime->today_local->year)->subtract(months => 1);
38 45

  
SL/InstallationCheck.pm
62 62
  { name => "Text::CSV_XS",    version => '0.23',  url => "http://search.cpan.org/~hmbrand/",   debian => 'libtext-csv-xs-perl' },
63 63
  { name => "Text::Iconv",     version => '1.2',   url => "http://search.cpan.org/~mpiotr/",    debian => 'libtext-iconv-perl' },
64 64
  { name => "Text::Unidecode",                     url => "http://search.cpan.org/~sburke/",    debian => 'libtext-unidecode-perl' },
65
  { name => "Try::Tiny",                           url => "https://metacpan.org/release/Try-Tiny",  debian => 'libtry-tiny-perl' },
65 66
  { name => "URI",             version => '1.35',  url => "http://search.cpan.org/~gaas/",      debian => 'liburi-perl' },
66 67
  { name => "XML::LibXML",                         url => "https://metacpan.org/pod/XML::LibXML", debian => 'libxml-libxml-perl' },
67 68
  { name => "XML::Writer",     version => '0.602', url => "http://search.cpan.org/~josephw/",   debian => 'libxml-writer-perl' },

Auch abrufbar als: Unified diff