Changeset a75ca74156bfac8b92c3b87b2c120d446dcf5345

Show
Ignore:
Timestamp:
11/06/09 22:32:54 (10 months ago)
Author:
Stephen Bennett <spb@…>
Parents:
20b3fcc6b52236b404b7d7aaf1517f57be3f84a2
Children:
41a47f14b962f658a0805dd7d3183fd9cb2d8728
git-committer:
Stephen Bennett <spb@exherbo.org> / 2009-11-06T22:32:54Z+0000
Message:

Translate DBIC exceptions from inserting channel namespaces to something more intelligible, where possible

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • lib/GMS/Schema/Result/ChannelNamespace.pm

    r71bc43c ra75ca74  
    33use warnings; 
    44use base 'DBIx::Class'; 
     5 
     6use TryCatch; 
    57 
    68__PACKAGE__->load_components('Core'); 
     
    1012__PACKAGE__->belongs_to('group', 'GMS::Schema::Result::Group', 'group_id'); 
    1113 
     14sub insert { 
     15    my $self = shift; 
     16    try { 
     17        return $self->next::method(@_); 
     18    } 
     19    catch (DBIx::Class::Exception $e) { 
     20        if ("$e" =~ /unique_channel_ns/) { 
     21            die GMS::Exception->new("The channel namespace " . $self->namespace . 
     22                                    " has already been claimed."); 
     23        } else { 
     24            die $e; 
     25        } 
     26    } 
     27} 
     28 
    12291;