Skip to content

Commit

Permalink
refless
Browse files Browse the repository at this point in the history
  • Loading branch information
smklein committed Oct 6, 2023
1 parent f1c045d commit 8c7e0ad
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 12 deletions.
1 change: 0 additions & 1 deletion nexus/db-queries/src/db/datastore/silo_group.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ use async_bb8_diesel::AsyncConnection;
use async_bb8_diesel::AsyncRunQueryDsl;
use chrono::Utc;
use diesel::prelude::*;
use diesel::OptionalExtension;
use omicron_common::api::external::CreateResult;
use omicron_common::api::external::DataPageParams;
use omicron_common::api::external::DeleteResult;
Expand Down
19 changes: 9 additions & 10 deletions nexus/db-queries/src/db/queries/network_interface.rs
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ fn decode_database_error(
// that colum has been violated.
DieselError::DatabaseError(
DatabaseErrorKind::NotNullViolation,
ref info,
info,
) if info.message() == IP_EXHAUSTION_ERROR_MESSAGE => {
InsertError::NoAvailableIpAddresses
}
Expand All @@ -300,18 +300,17 @@ fn decode_database_error(
// `push_ensure_unique_vpc_expression` subquery, which generates a
// UUID parsing error if the resource (e.g. instance) we want to attach
// to is already associated with another VPC.
DieselError::DatabaseError(DatabaseErrorKind::Unknown, ref info)
DieselError::DatabaseError(DatabaseErrorKind::Unknown, info)
if info.message() == MULTIPLE_VPC_ERROR_MESSAGE =>
{
InsertError::ResourceSpansMultipleVpcs(interface.parent_id)
}

// This checks the constraint on the interface slot numbers, used to
// limit total number of interfaces per resource to a maximum number.
DieselError::DatabaseError(
DatabaseErrorKind::CheckViolation,
ref info,
) if info.message() == NO_SLOTS_AVAILABLE_ERROR_MESSAGE => {
DieselError::DatabaseError(DatabaseErrorKind::CheckViolation, info)
if info.message() == NO_SLOTS_AVAILABLE_ERROR_MESSAGE =>
{
InsertError::NoSlotsAvailable
}

Expand All @@ -320,7 +319,7 @@ fn decode_database_error(
// that column has been violated.
DieselError::DatabaseError(
DatabaseErrorKind::NotNullViolation,
ref info,
info,
) if info.message() == MAC_EXHAUSTION_ERROR_MESSAGE => {
InsertError::NoMacAddrressesAvailable
}
Expand All @@ -329,7 +328,7 @@ fn decode_database_error(
// `push_ensure_unique_vpc_subnet_expression` subquery, which generates
// a UUID parsing error if the resource has another interface in the VPC
// Subnet of the one we're trying to insert.
DieselError::DatabaseError(DatabaseErrorKind::Unknown, ref info)
DieselError::DatabaseError(DatabaseErrorKind::Unknown, info)
if info.message() == NON_UNIQUE_VPC_SUBNET_ERROR_MESSAGE =>
{
InsertError::NonUniqueVpcSubnets
Expand All @@ -338,7 +337,7 @@ fn decode_database_error(
// This catches the UUID-cast failure intentionally introduced by
// `push_instance_state_verification_subquery`, which verifies that
// the instance is actually stopped when running this query.
DieselError::DatabaseError(DatabaseErrorKind::Unknown, ref info)
DieselError::DatabaseError(DatabaseErrorKind::Unknown, info)
if info.message() == INSTANCE_BAD_STATE_ERROR_MESSAGE =>
{
assert_eq!(interface.kind, NetworkInterfaceKind::Instance);
Expand All @@ -347,7 +346,7 @@ fn decode_database_error(
// This catches the UUID-cast failure intentionally introduced by
// `push_instance_state_verification_subquery`, which verifies that
// the instance doesn't even exist when running this query.
DieselError::DatabaseError(DatabaseErrorKind::Unknown, ref info)
DieselError::DatabaseError(DatabaseErrorKind::Unknown, info)
if info.message() == NO_INSTANCE_ERROR_MESSAGE =>
{
assert_eq!(interface.kind, NetworkInterfaceKind::Instance);
Expand Down
2 changes: 1 addition & 1 deletion nexus/db-queries/src/db/true_or_cast_error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ pub fn matches_sentinel(
match e {
// Catch the specific errors designed to communicate the failures we
// want to distinguish.
Error::DatabaseError(DatabaseErrorKind::Unknown, ref info) => {
Error::DatabaseError(DatabaseErrorKind::Unknown, info) => {
for sentinel in sentinels {
if info.message() == bool_parse_error(sentinel) {
return Some(sentinel);
Expand Down

0 comments on commit 8c7e0ad

Please sign in to comment.