6:49 PM 0 0
ResponseException Model

ResponseException Model

  Sergi |  December 182021
using System;

namespace BlazorIndexedDb.Models
{
///
/// Manage own exceptions
///

public class ResponseException : Exception
{
///
/// Command throw the exception
///

public string Command { get; set; }
///
/// Store name throw the exception
///

public string StoreName { get; set; }
///
/// Data inside the transaction if have
///

public string TransactionData { get; set; }
///
/// Basic constructor
///

public ResponseException():base() { }
///
/// Constructor with message
///

public ResponseException(string message):base(message) { }
///
/// Contructur with message and exception
///

public ResponseException(string message, Exception innerException):base(message, innerException) { }

///
/// Basic internal constructor
///

///
///
///
public ResponseException(string command, string storeName, string data) : base($"[{command}] {storeName}") =>
(Command, StoreName, TransactionData) = (command, storeName, data);
///
/// Constructor with the inner Exception
///

///
///
///
///
public ResponseException(string command, string storeName, string data, Exception innerException): base($"[{command}] {storeName}", innerException) =>
(Command, StoreName, TransactionData) = (command, storeName, data);
///
/// Return error formated
///

///
public override string ToString() =>
$"{this.Message} {(string.IsNullOrEmpty(this.TransactionData) ? "" : $"({this.TransactionData})")}";
}
}

Used when have some exception from the insert, uptade, delete or select actiontions.


0 Guest reviews

 
 
 

File