Data::...Errors(3pm)

πŸ’… Data::ObjectDriver::Errors β€” the vibes

okay bestie, so this is a page from User Contributed Perl Documentation, section 3pm, and the star of the show is the module Data::ObjectDriver::Errors. It's a whole container class for common database error codes. Container class, like a cute lil' box that holds your error constants. We love a tidy queen. πŸŽ€


✨ NAME ✨

Data::ObjectDriver::Errors β€” container class for common database error codes, periodt. πŸ’…


πŸ¦‹ SYNOPSIS πŸ¦‹

eval { $driver->insert($obj); };
if ($@ && $driver->last_error() == Data::ObjectDriver::Errors->UNIQUE_CONSTRAINT) {
    ...
}

like, you wrap the risky insert in an eval, and then if $@ is truthy and $driver->last_error() equals Data::ObjectDriver::Errors->UNIQUE_CONSTRAINT, you know exactly what happened. iykyk. ✨


🌸 DESCRIPTION 🌸

Data::ObjectDriver::Errors is a container class for error codes that come out of DBI database operations. that's literally its whole job and it does it flawlessly. πŸ‘‘

the way it works: database drivers can map the particular DBI errors of their particular database servers onto these constants, using their map_error_code methods. so your code doesn't have to care which database server was being dramatic β€” the driver translates, and you get the same tidy constant every time. 🫢


πŸ’– DEFINED ERROR CODES πŸ’–

  • UNIQUE_CONSTRAINT β€” the application issued an insert or update that would violate the uniqueness constraint on a particular column. classic example: attempting to save a duplicate value to an indexed key field. no cap, the database said "not today" πŸ’€

🌈 SEE ALSO 🌈

  • "Data::ObjectDriver::Driver::DBD::map_error_code" β€” go read that one next, bestie, it's the whole mapping situation πŸ’œ

πŸ”₯ LICENSE πŸ”₯

Data::ObjectDriver is free software; you may redistribute it and/or modify it under the same terms as Perl itself. slay, honestly. 🧚


Except where otherwise noted, Data::ObjectDriver is Copyright 2005-2006 Six Apart, cpan@sixapart.com. All rights reserved. iconic behavior, truly. πŸŽ€


and that's the whole page, bestie β€” packed up with a cute lil' bow πŸŽ€ from perl v5.42.0, dated 2024-10-24, still out here doing Data::...Errors(3pm) things. mwah. πŸ’–

πŸ“¦ where this page comes from