Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision cb53cdd0

Von Sven Schöling vor mehr als 3 Jahren hinzugefügt

  • ID cb53cdd0f403a22c4257ac75204ae4cc5fb8710f
  • Vorgänger c22e188b
  • Nachfolger b1e8bade

Inventory: Exception Klassen korrigiert

Exception::Class behandelt message und error speziell, und dadurch
gingen im portierten Inventory Helper feature die exceptions kaputt.

In SL::X ist jetzt ein Kommentar der das beschreibt.

Unterschiede anzeigen:

SL/Helper/Inventory.pm
197 197
  }
198 198
  if ($rest_qty > 0) {
199 199
    die SL::X::Inventory::Allocation->new(
200
      error => 'not enough to allocate',
201
      msg => t8("can not allocate #1 units of #2, missing #3 units", _format_number($qty), $part->displayable_name, _format_number($rest_qty)),
200
      code    => 'not enough to allocate',
201
      message => t8("can not allocate #1 units of #2, missing #3 units", _format_number($qty), $part->displayable_name, _format_number($rest_qty)),
202 202
    );
203 203
  } else {
204 204
    if ($params{constraints}) {
......
238 238
  if ('CODE' eq ref $constraints) {
239 239
    if (!$constraints->(@$allocations)) {
240 240
      die SL::X::Inventory::Allocation->new(
241
        error => 'allocation constraints failure',
242
        msg => t8("Allocations didn't pass constraints"),
241
        code    => 'allocation constraints failure',
242
        message => t8("Allocations didn't pass constraints"),
243 243
      );
244 244
    }
245 245
  } else {
......
272 272
              SL::DB::Bin->load_cached($_->bin_id)->full_description,
273 273
              _format_number($_->qty), _format_number($needed), $_->chargenumber ? $_->chargenumber : '--') for @allocs;
274 274
        die SL::X::Inventory::Allocation->new(
275
          error => 'allocation constraints failure',
276
          msg   => $err,
275
          code    => 'allocation constraints failure',
276
          message => $err,
277 277
        );
278 278
      }
279 279
    }
......
319 319
      $allocations_by_part{ $assembly->parts_id } -= $assembly->qty * $qty;
320 320
    }
321 321

  
322
    die "allocations are insufficient for production" if any { $_ < 0 } values %allocations_by_part;
322
    die SL::X::Inventory::Allocation->new(
323
      code    => "allocations are insufficient for production",
324
      message => t8('can not allocate enough resources for production'),
325
    ) if any { $_ < 0 } values %allocations_by_part;
323 326
  }
324 327

  
325 328
  my @transfers;
SL/X.pm
5 5

  
6 6
use SL::X::Base;
7 7

  
8

  
9
# note! the default fields "message", "error" and "show_trace" are created by
10
# Exception::Class if message or error are given, they are used for
11
# stringification, so don't use them in error_templates
12
#
8 13
use Exception::Class (
9 14
  'SL::X::FormError'    => {
10 15
    isa                 => 'SL::X::Base',
......
32 37
  },
33 38
  'SL::X::Inventory' => {
34 39
    isa                 => 'SL::X::Base',
35
    fields              => [ qw(msg error) ],
36
    defaults            => { error_template => [ '%s: %s', qw(msg) ] },
40
    fields              => [ qw(code) ],
37 41
  },
38 42
  'SL::X::Inventory::Allocation' => {
39 43
    isa                 => 'SL::X::Base',
40
    fields              => [ qw(msg error) ],
41
    defaults            => { error_template => [ '%s: %s', qw(msg) ] },
44
    fields              => [ qw(code) ],
42 45
  },
43 46
);
44 47

  

Auch abrufbar als: Unified diff