Skip to content

Commit

Permalink
CODE RUB: Extended exceptions to take an inner exception
Browse files Browse the repository at this point in the history
  • Loading branch information
cjdutoit committed Feb 20, 2024
1 parent 605ba00 commit ecf870d
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,15 @@
// Copyright (c) The Standard Organization: A coalition of the Good-Hearted Engineers
// ----------------------------------------------------------------------------------

using System;
using Microsoft.EntityFrameworkCore;

namespace STX.EFxceptions.Abstractions.Models.Exceptions
{
public class DuplicateKeyException : DbUpdateException
{
public DuplicateKeyException(string message) : base(message) { }

public DuplicateKeyException(string message, Exception innerException) : base(message, innerException) { }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// Copyright (c) The Standard Organization: A coalition of the Good-Hearted Engineers
// ----------------------------------------------------------------------------------

using System;
using Microsoft.EntityFrameworkCore;

namespace STX.EFxceptions.Abstractions.Models.Exceptions
Expand All @@ -20,5 +21,16 @@ public DuplicateKeyWithUniqueIndexException(string message)
DuplicateKeyValue = subStrings[1];
}
}

public DuplicateKeyWithUniqueIndexException(string message, Exception innerException)
: base(message, innerException)
{
string[] subStrings = message.Split('(', ')');

if (subStrings.Length == 3)
{
DuplicateKeyValue = subStrings[1];
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,16 @@
// Copyright (c) The Standard Organization: A coalition of the Good-Hearted Engineers
// ----------------------------------------------------------------------------------

using System;
using Microsoft.EntityFrameworkCore;

namespace STX.EFxceptions.Abstractions.Models.Exceptions
{
public class ForeignKeyConstraintConflictException : DbUpdateException
{
public ForeignKeyConstraintConflictException(string message) : base(message) { }

public ForeignKeyConstraintConflictException(string message, Exception innerException)
: base(message, innerException) { }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@
// Copyright (c) The Standard Organization: A coalition of the Good-Hearted Engineers
// ----------------------------------------------------------------------------------

using System;
using Microsoft.EntityFrameworkCore;

namespace STX.EFxceptions.Abstractions.Models.Exceptions
{
public class InvalidColumnNameException : DbUpdateException
{
public InvalidColumnNameException(string message) : base(message) { }
public InvalidColumnNameException(string message, Exception innerException) : base(message, innerException) { }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@
// Copyright (c) The Standard Organization: A coalition of the Good-Hearted Engineers
// ----------------------------------------------------------------------------------

using System;
using Microsoft.EntityFrameworkCore;

namespace STX.EFxceptions.Abstractions.Models.Exceptions
{
public class InvalidObjectNameException : DbUpdateException
{
public InvalidObjectNameException(string message) : base(message) { }
public InvalidObjectNameException(string message, Exception innerException) : base(message, innerException) { }
}
}

0 comments on commit ecf870d

Please sign in to comment.