Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 80b313fa

Von Martin Helmling martin.helmling@octosoft.eu vor fast 8 Jahren hinzugefügt

  • ID 80b313fae445a6aa45a26561c0fd4ab364cb99ce
  • Vorgänger 19f08831
  • Nachfolger a4684ad1

Fehlerbehandlung in SL/File.pm vereinfacht

Unterschiede anzeigen:

SL/File.pm
123 123
sub delete {
124 124
  my ($self, %params) = @_;
125 125
  die "no id or dbfile" unless $params{id} || $params{dbfile};
126
  my $rc = SL::DB->client->with_transaction(\&_delete, $self, %params);
127
  if (!$rc) {
128
    my $err = SL::DB->client->error;
129
    die $err?(ref $err?$$err:$err):"unknown err";
130
  }
126
  my $rc = 0;
127
  eval {
128
    $rc = SL::DB->client->with_transaction(\&_delete, $self, %params);
129
    1;
130
  } or do { die $@ };
131 131
  return $rc;
132 132
}
133 133

  
......
149 149

  
150 150
    if ($hist) {
151 151
      if (!$main::auth->assert('import_ar | import_ap', 1)) {
152
        die \'no permission to unimport';
152
        die 'no permission to unimport';
153 153
      }
154 154
      my $file = $backend->get_filepath(dbfile => $params{dbfile});
155 155
      $main::lxdebug->message(LXDebug->DEBUG2(), "del file=" . $file . " to=" . $hist->snumbers);
......
179 179
sub save {
180 180
  my ($self, %params) = @_;
181 181

  
182
  my $obj = SL::DB->client->with_transaction(\&_save, $self, %params);
183
  if (!$obj) {
184
    my $err = SL::DB->client->error;
185
    die (ref $err?$$err:$err);
186
  }
182
  my $obj;
183
  eval {
184
    $obj = SL::DB->client->with_transaction(\&_save, $self, %params);
185
    1;
186
  } or do { die $@ };
187 187
  return $obj;
188 188
}
189 189

  
......
194 194

  
195 195
  if ($params{id}) {
196 196
    $file = SL::DB::File->new(id => $params{id})->load;
197
    die \'dbfile not exists'     unless $file;
197
    die 'dbfile not exists'     unless $file;
198 198
  } elsif (!$file) {
199 199
  $main::lxdebug->message(LXDebug->DEBUG2(), "obj_id=" .$params{object_id});
200
    die \'no object type set'    unless $params{object_type};
201
    die \'no object id set'      unless defined($params{object_id});
200
    die 'no object type set'    unless $params{object_type};
201
    die 'no object id set'      unless defined($params{object_id});
202 202

  
203 203
    $exists = $self->get_all_count(%params);
204 204
    die 'filename still exist' if $exists && $params{fail_if_exists};
......
322 322
  eval {
323 323
    eval "require $class";
324 324
    $obj = $class->new;
325
    die \'backend not enabled' unless $obj->enabled;
325
    die 'backend not enabled' unless $obj->enabled;
326 326
    1;
327 327
  } or do {
328
    die \'backend class not found';
328
    die 'backend class not found';
329 329
  };
330 330
  return $obj;
331 331
}

Auch abrufbar als: Unified diff