Skip to content

Commit

Permalink
Add API description for Azure PowerShell exceptions. (#246)
Browse files Browse the repository at this point in the history
  • Loading branch information
erich-wang authored Feb 1, 2021
1 parent 8717aad commit fe5b728
Show file tree
Hide file tree
Showing 12 changed files with 468 additions and 2 deletions.
32 changes: 32 additions & 0 deletions src/Common/Exceptions/AzPSApplicationException.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,32 +18,55 @@

namespace Microsoft.Azure.Commands.Common.Exceptions
{
/// <summary>
/// Representive of ApplicationException in Azure PowerShell.
/// </summary>
public class AzPSApplicationException : ApplicationException, IContainsAzPSErrorData
{
/// <summary>
/// ErrorKind that causes this exception.
/// </summary>
public ErrorKind ErrorKind
{
get => Data.GetValue<ErrorKind>(AzurePSErrorDataKeys.ErrorKindKey);
private set => Data.SetValue(AzurePSErrorDataKeys.ErrorKindKey, value);
}

/// <summary>
/// The error message which doesn't contain PII.
/// </summary>
public string DesensitizedErrorMessage
{
get => Data.GetValue<string>(AzurePSErrorDataKeys.DesensitizedErrorMessageKey);
private set => Data.SetValue(AzurePSErrorDataKeys.DesensitizedErrorMessageKey, value);
}

/// <summary>
/// The number of line when exception happens.
/// </summary>
public int? ErrorLineNumber
{
get => Data.GetNullableValue<int>(AzurePSErrorDataKeys.ErrorLineNumberKey);
private set => Data.SetValue(AzurePSErrorDataKeys.ErrorLineNumberKey, value);
}

/// <summary>
/// The file name when exception happens.
/// </summary>
public string ErrorFileName
{
get => Data.GetValue<string>(AzurePSErrorDataKeys.ErrorFileNameKey);
private set => Data.SetValue(AzurePSErrorDataKeys.ErrorFileNameKey, value);
}

/// <summary>
/// Construtor of AzPSApplicationException
/// </summary>
/// <param name="message">The error message that explains the reason for the exception.</param>
/// <param name="innerException">The exception that is the cause of the current exception. Default value is null.</param>
/// <param name="desensitizedMessage">The error message which doesn't contain PII.</param>
/// <param name="lineNumber">The number of line when exception happens.</param>
/// <param name="filePath">The file path when exception happens.</param>
public AzPSApplicationException(
string message,
Exception innerException = null,
Expand All @@ -54,6 +77,15 @@ public AzPSApplicationException(
{
}

/// <summary>
/// Constructor of AzPSApplicationException
/// </summary>
/// <param name="message">The error message that explains the reason for the exception.</param>
/// <param name="errorKind">ErrorKind that causes this exception.</param>
/// <param name="innerException">The exception that is the cause of the current exception. Default value is null.</param>
/// <param name="desensitizedMessage">The error message which doesn't contain PII.</param>
/// <param name="lineNumber">The number of line when exception happens.</param>
/// <param name="filePath">The file path when exception happens.</param>
public AzPSApplicationException(
string message,
ErrorKind errorKind,
Expand Down
52 changes: 52 additions & 0 deletions src/Common/Exceptions/AzPSArgumentException.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,38 +19,64 @@

namespace Microsoft.Azure.Commands.Common.Exceptions
{
/// <summary>
/// Representive of ArgumentException in Azure PowerShell
/// </summary>
public class AzPSArgumentException : PSArgumentException, IContainsAzPSErrorData
{
/// <summary>
/// The parameter name that results in this exception.
/// </summary>
private string ErrorParamName
{
get => Data.GetValue<string>(AzurePSErrorDataKeys.ParamNameKey);
set => Data.SetValue(AzurePSErrorDataKeys.ParamNameKey, value);
}

/// <summary>
/// ErrorKind that causes this exception.
/// </summary>
public ErrorKind ErrorKind
{
get => Data.GetValue<ErrorKind>(AzurePSErrorDataKeys.ErrorKindKey);
private set => Data.SetValue(AzurePSErrorDataKeys.ErrorKindKey, value);
}

/// <summary>
/// The error message which doesn't contain PII.
/// </summary>
public string DesensitizedErrorMessage
{
get => Data.GetValue<string>(AzurePSErrorDataKeys.DesensitizedErrorMessageKey);
private set => Data.SetValue(AzurePSErrorDataKeys.DesensitizedErrorMessageKey, value);
}

/// <summary>
/// The number of line when exception happens.
/// </summary>
public int? ErrorLineNumber
{
get => Data.GetNullableValue<int>(AzurePSErrorDataKeys.ErrorLineNumberKey);
private set => Data.SetValue(AzurePSErrorDataKeys.ErrorLineNumberKey, value);
}

/// <summary>
/// The file name when exception happens.
/// </summary>
public string ErrorFileName
{
get => Data.GetValue<string>(AzurePSErrorDataKeys.ErrorFileNameKey);
private set => Data.SetValue(AzurePSErrorDataKeys.ErrorFileNameKey, value);
}

/// <summary>
/// Construtor of AzPSArgumentException
/// </summary>
/// <param name="message">The error message that explains the reason for the exception.</param>
/// <param name="paramName">The parameter name that results in this exception.</param>
/// <param name="desensitizedMessage">The error message which doesn't contain PII.</param>
/// <param name="lineNumber">The number of line when exception happens.</param>
/// <param name="filePath">The file path when exception happens.</param>
public AzPSArgumentException(
string message,
string paramName,
Expand All @@ -61,6 +87,15 @@ public AzPSArgumentException(
{
}

/// <summary>
/// Construtor of AzPSArgumentException
/// </summary>
/// <param name="message">The error message that explains the reason for the exception.</param>
/// <param name="paramName">The parameter name that results in this exception.</param>
/// <param name="errorKind">ErrorKind that causes this exception.</param>
/// <param name="desensitizedMessage">The error message which doesn't contain PII.</param>
/// <param name="lineNumber">The number of line when exception happens.</param>
/// <param name="filePath">The file path when exception happens.</param>
public AzPSArgumentException(
string message,
string paramName,
Expand All @@ -81,6 +116,14 @@ public AzPSArgumentException(
}
}

/// <summary>
/// Construtor of AzPSArgumentException
/// </summary>
/// <param name="message">The error message that explains the reason for the exception.</param>
/// <param name="innerException">The exception that is the cause of the current exception. Default value is null.</param>
/// <param name="desensitizedMessage">The error message which doesn't contain PII.</param>
/// <param name="lineNumber">The number of line when exception happens.</param>
/// <param name="filePath">The file path when exception happens.</param>
public AzPSArgumentException(
string message,
Exception innerException,
Expand All @@ -91,6 +134,15 @@ public AzPSArgumentException(
{
}

/// <summary>
/// Construtor of AzPSArgumentException
/// </summary>
/// <param name="message">The error message that explains the reason for the exception.</param>
/// <param name="innerException">The exception that is the cause of the current exception. Default value is null.</param>
/// <param name="errorKind">ErrorKind that causes this exception.</param>
/// <param name="desensitizedMessage">The error message which doesn't contain PII.</param>
/// <param name="lineNumber">The number of line when exception happens.</param>
/// <param name="filePath">The file path when exception happens.</param>
public AzPSArgumentException(
string message,
Exception innerException,
Expand Down
52 changes: 52 additions & 0 deletions src/Common/Exceptions/AzPSArgumentNullException.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,38 +19,64 @@

namespace Microsoft.Azure.Commands.Common.Exceptions
{
/// <summary>
/// Representive of ArgumentNullException in Azure PowerShell
/// </summary>
public class AzPSArgumentNullException : PSArgumentNullException, IContainsAzPSErrorData
{
/// <summary>
/// The parameter name that results in this exception.
/// </summary>
private string ErrorParamName
{
get => Data.GetValue<string>(AzurePSErrorDataKeys.ParamNameKey);
set => Data.SetValue(AzurePSErrorDataKeys.ParamNameKey, value);
}

/// <summary>
/// ErrorKind that causes this exception.
/// </summary>
public ErrorKind ErrorKind
{
get => Data.GetValue<ErrorKind>(AzurePSErrorDataKeys.ErrorKindKey);
private set => Data.SetValue(AzurePSErrorDataKeys.ErrorKindKey, value);
}

/// <summary>
/// The error message which doesn't contain PII.
/// </summary>
public string DesensitizedErrorMessage
{
get => Data.GetValue<string>(AzurePSErrorDataKeys.DesensitizedErrorMessageKey);
private set => Data.SetValue(AzurePSErrorDataKeys.DesensitizedErrorMessageKey, value);
}

/// <summary>
/// The number of line when exception happens.
/// </summary>
public int? ErrorLineNumber
{
get => Data.GetNullableValue<int>(AzurePSErrorDataKeys.ErrorLineNumberKey);
private set => Data.SetValue(AzurePSErrorDataKeys.ErrorLineNumberKey, value);
}

/// <summary>
/// The file name when exception happens.
/// </summary>
public string ErrorFileName
{
get => Data.GetValue<string>(AzurePSErrorDataKeys.ErrorFileNameKey);
private set => Data.SetValue(AzurePSErrorDataKeys.ErrorFileNameKey, value);
}

/// <summary>
/// Construtor of AzPSArgumentNullException
/// </summary>
/// <param name="message">The error message that explains the reason for the exception.</param>
/// <param name="paramName">The parameter name that results in this exception.</param>
/// <param name="desensitizedMessage">The error message which doesn't contain PII.</param>
/// <param name="lineNumber">The number of line when exception happens.</param>
/// <param name="filePath">The file path when exception happens.</param>
public AzPSArgumentNullException(
string message,
string paramName,
Expand All @@ -61,6 +87,15 @@ public AzPSArgumentNullException(
{
}

/// <summary>
/// Construtor of AzPSArgumentNullException
/// </summary>
/// <param name="message">The error message that explains the reason for the exception.</param>
/// <param name="paramName">The parameter name that results in this exception.</param>
/// <param name="errorKind">ErrorKind that causes this exception.</param>
/// <param name="desensitizedMessage">The error message which doesn't contain PII.</param>
/// <param name="lineNumber">The number of line when exception happens.</param>
/// <param name="filePath">The file path when exception happens.</param>
public AzPSArgumentNullException(
string message,
string paramName,
Expand All @@ -80,6 +115,14 @@ public AzPSArgumentNullException(
}
}

/// <summary>
/// Construtor of AzPSArgumentNullException
/// </summary>
/// <param name="message">The error message that explains the reason for the exception.</param>
/// <param name="innerException">The exception that is the cause of the current exception. Default value is null.</param>
/// <param name="desensitizedMessage">The error message which doesn't contain PII.</param>
/// <param name="lineNumber">The number of line when exception happens.</param>
/// <param name="filePath">The file path when exception happens.</param>
public AzPSArgumentNullException(
string message,
Exception innerException,
Expand All @@ -90,6 +133,15 @@ public AzPSArgumentNullException(
{
}

/// <summary>
/// Construtor of AzPSArgumentNullException
/// </summary>
/// <param name="message">The error message that explains the reason for the exception.</param>
/// <param name="innerException">The exception that is the cause of the current exception. Default value is null.</param>
/// <param name="errorKind">ErrorKind that causes this exception.</param>
/// <param name="desensitizedMessage">The error message which doesn't contain PII.</param>
/// <param name="lineNumber">The number of line when exception happens.</param>
/// <param name="filePath">The file path when exception happens.</param>
public AzPSArgumentNullException(
string message,
Exception innerException,
Expand Down
Loading

0 comments on commit fe5b728

Please sign in to comment.