Skip to content

Commit

Permalink
Merge pull request #103 from aosunlana/users/aosunlana/code-rub-upgra…
Browse files Browse the repository at this point in the history
…de-test-to-standard2101

CODE RUB: Upgrade Test to Standard `2.10.1`
  • Loading branch information
hassanhabib authored Apr 14, 2024
2 parents d485075 + 1995e99 commit 44e9f40
Show file tree
Hide file tree
Showing 27 changed files with 185 additions and 142 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,6 @@ namespace ADotNet.Models.Foundations.Files.Exceptions
{
public class FailedFileSerializationException : Xeption
{
public FailedFileSerializationException(Exception innerException)
: base(message: "Failed file serialization error occurred, contact support.",
innerException: innerException)
{ }

public FailedFileSerializationException(string message, Exception innerException)
: base(message, innerException)
{ }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,6 @@ namespace ADotNet.Models.Foundations.Files.Exceptions
{
public class FailedFileServiceException : Xeption
{
public FailedFileServiceException(Exception innerException)
: base(message: "Failed file service error occurred, contact support.",
innerException: innerException)
{ }

public FailedFileServiceException(string message, Exception innerException)
: base(message, innerException)
{ }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,6 @@ namespace ADotNet.Models.Foundations.Files.Exceptions
{
public class FileDependencyException : Xeption
{
public FileDependencyException(Xeption innerException)
: base(message: "File dependency error occurred, contact support.",
innerException: innerException)
{ }

public FileDependencyException(string message, Xeption innerException)
: base(message, innerException)
{ }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,14 @@
// See License.txt in the project root for license information.
// ---------------------------------------------------------------

using System;
using Xeptions;

namespace ADotNet.Models.Foundations.Files.Exceptions
{
public class FileDependencyValidationException : Xeption
{
public FileDependencyValidationException(Xeption innerException)
: base(message: "File dependency validation error occurred, fix the errors and try again.",
innerException: innerException)
{ }

public FileDependencyValidationException(string message, Xeption innerException)
public FileDependencyValidationException(string message, Exception innerException)
: base(message, innerException)
{ }
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,6 @@ namespace ADotNet.Models.Foundations.Files.Exceptions
{
public class FileServiceException : Xeption
{
public FileServiceException(Xeption innerException)
: base(message: "File service error occurred, contact support.",
innerException: innerException)
{ }

public FileServiceException(string message, Xeption innerException)
: base(message, innerException)
{ }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,6 @@ namespace ADotNet.Models.Foundations.Files.Exceptions
{
public class FileValidationException : Xeption
{
public FileValidationException(Xeption innerException)
: base(message: "File validation error occurred, fix the errors and try again.",
innerException: innerException)
{ }

public FileValidationException(string message, Xeption innerException)
: base(message, innerException)
{ }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,6 @@ namespace ADotNet.Models.Foundations.Files.Exceptions
{
public class InvalidFileContentException : Xeption
{
public InvalidFileContentException()
: base(message: "Invalid file content, fix errors and try again.")
{ }

public InvalidFileContentException(string message)
: base(message)
{ }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,6 @@ namespace ADotNet.Models.Foundations.Files.Exceptions
{
public class InvalidFileException : Xeption
{
public InvalidFileException(Exception innerException)
: base(message: "Invalid file error occurred.",
innerException: innerException)
{ }

public InvalidFileException(string message, Exception innerException)
: base(message, innerException)
{ }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,6 @@ namespace ADotNet.Models.Foundations.Files.Exceptions
{
public class InvalidFilePathException : Xeption
{
public InvalidFilePathException()
: base(message: "Invalid file path, fix the errors and try again.")
{ }

public InvalidFilePathException(string message)
: base(message)
{ }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,10 @@

using System;

namespace ADotNet.Models.Pipelines.Exceptions
namespace ADotNet.Models.Pipelines.AdoPipelines.Exceptions
{
public class AdoDependencyException : Exception
{
public AdoDependencyException(Exception innerException)
: base(message: "Ado dependency error occured, contact support.",
innerException: innerException)
{ }

public AdoDependencyException(string message, Exception innerException)
: base(message, innerException)
{ }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,10 @@

using System;

namespace ADotNet.Models.Pipelines.Exceptions
namespace ADotNet.Models.Pipelines.AdoPipelines.Exceptions
{
public class AdoDependencyValidationException : Exception
{
public AdoDependencyValidationException(Exception innerException)
: base(message: "Ado dependency validation error occured, try again.",
innerException: innerException)
{ }

public AdoDependencyValidationException(string message, Exception innerException)
: base(message, innerException)
{ }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,10 @@

using System;

namespace ADotNet.Models.Pipelines.Exceptions
namespace ADotNet.Models.Pipelines.AdoPipelines.Exceptions
{
public class AdoValidationException : Exception
{
public AdoValidationException(Exception innerException)
: base(message: "Ado validation exception occurred, try again",
innerException: innerException)
{ }

public AdoValidationException(string message,Exception innerException)
: base(message, innerException)
{ }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,10 @@

using System;

namespace ADotNet.Models.Pipelines.Exceptions
namespace ADotNet.Models.Pipelines.AdoPipelines.Exceptions
{
public class BuildServiceException : Exception
{
public BuildServiceException(Exception innerException)
: base(message: "Build service exception occured, contact support.",
innerException: innerException)
{ }

public BuildServiceException(string message, Exception innerException)
: base(message, innerException)
{ }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,12 @@
// See License.txt in the project root for license information.
// ---------------------------------------------------------------------------

using System;
using Xeptions;

namespace ADotNet.Models.Pipelines.Exceptions
namespace ADotNet.Models.Pipelines.AdoPipelines.Exceptions
{
public class NullPathException : Exception
public class NullPathException : Xeption
{
public NullPathException()
: base(message: "Path is null")
{ }

public NullPathException(string message)
: base(message)
{ }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,12 @@
// ---------------------------------------------------------------------------

using System;
using Xeptions;

namespace ADotNet.Models.Pipelines.Exceptions
namespace ADotNet.Models.Pipelines.AdoPipelines.Exceptions
{
public class NullPipelineException : Exception
public class NullPipelineException : Xeption
{
public NullPipelineException()
: base(message: "Pipeline is null")
{ }

public NullPipelineException(string message)
: base(message)
{ }
Expand Down
58 changes: 44 additions & 14 deletions ADotNet/Services/Builds/BuildService.Exceptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
using System;
using System.IO;
using System.Security;
using ADotNet.Models.Pipelines.Exceptions;
using ADotNet.Models.Pipelines.AdoPipelines.Exceptions;
using Xeptions;

namespace ADotNet.Services.Builds
{
Expand All @@ -23,49 +24,78 @@ private static void TryCatch(ReturningNothingFunction returningNothingFunction)
}
catch (NullPipelineException nullPipelineException)
{
throw new AdoValidationException(nullPipelineException);
throw CreateAdoValidationException(nullPipelineException);
}
catch (NullPathException nullPathException)
{
throw new AdoValidationException(nullPathException);
throw CreateAdoValidationException(nullPathException);
}
catch (ArgumentNullException argumentNullException)
{
throw new AdoDependencyValidationException(argumentNullException);
throw CreateAdoDependencyValidationException(argumentNullException);
}
catch (ArgumentException argumentException)
{
throw new AdoDependencyValidationException(argumentException);
throw CreateAdoDependencyValidationException(argumentException);
}
catch (PathTooLongException pathTooLongException)
{
throw new AdoDependencyValidationException(pathTooLongException);
throw CreateAdoDependencyValidationException(pathTooLongException);
}
catch (DirectoryNotFoundException directoryNotFoundException)
{
throw new AdoDependencyValidationException(
directoryNotFoundException);
throw CreateAdoDependencyValidationException(directoryNotFoundException);
}
catch (IOException ioException)
{
throw new AdoDependencyException(ioException);
throw CreateAdoDependencyException(ioException);
}
catch (SecurityException securityException)
{
throw new AdoDependencyException(securityException);
throw CreateAdoDependencyException(securityException);
}
catch (UnauthorizedAccessException unauthorizedAccessException)
{
throw new AdoDependencyException(unauthorizedAccessException);
throw CreateAdoDependencyException(unauthorizedAccessException);
}
catch (NotSupportedException notSupportedException)
{
throw new AdoDependencyException(notSupportedException);
throw CreateAdoDependencyException(notSupportedException);
}
catch (Exception exception)
{
throw new BuildServiceException(exception);
throw CreateBuildServiceException(exception);
}
}

private static AdoValidationException CreateAdoValidationException(Xeption innerException)
{
return new AdoValidationException(
message: "Ado validation exception occurred, try again",
innerException: innerException);
}

private static AdoDependencyValidationException CreateAdoDependencyValidationException(
Exception innerException)
{
return new AdoDependencyValidationException(
message: "Ado dependency validation error occurs, try again.",
innerException: innerException);
}

private static AdoDependencyException CreateAdoDependencyException(
Exception innerException)
{
return new AdoDependencyException(
message: "Ado dependency error occured, contact support.",
innerException: innerException);
}

private static Exception CreateBuildServiceException(Exception innerException)
{
return new BuildServiceException(
message: "Build service exception occured, contact support.",
innerException: innerException);
}
}
}
}
7 changes: 4 additions & 3 deletions ADotNet/Services/Builds/BuildService.Validations.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// See License.txt in the project root for license information.
// ---------------------------------------------------------------------------

using ADotNet.Models.Pipelines.Exceptions;
using ADotNet.Models.Pipelines.AdoPipelines.Exceptions;

namespace ADotNet.Services.Builds
{
Expand All @@ -15,10 +15,11 @@ public static void ValidateInputs(string path, object pipeline)
switch (path, pipeline)
{
case (_, null):
throw new NullPipelineException();
throw new NullPipelineException(
message: "Pipeline is null");

case (null, _):
throw new NullPathException();
throw new NullPathException(message: "Path is null");
}
}
}
Expand Down
Loading

0 comments on commit 44e9f40

Please sign in to comment.