Imports System.Runtime.Serialization
Imports System.ServiceModel

Namespace Exceptions


    Public Class UnexpectedErrorException(Of UnexpectedErrorFault)
        Inherits FaultException

        Public Sub New()
            MyBase.New()
        End Sub
    End Class

    <DataContract>
    Public Class BaseFault
        ''' <summary>
        ''' The human readable error message
        ''' </summary>
        <DataMember>
        Public Property ErrorMessage As String

        <DataMember>
        Public Property InnerException As Exception

        <DataMember>
        Public Property IsRecoverable As Boolean = True
    End Class

    <DataContract>
    Public Class UnexpectedErrorFault
        Inherits BaseFault

        Public Sub New(Exception As Exception)
            MyBase.New()
            ErrorMessage = "Unexpected Error"
            IsRecoverable = True
            InnerException = Exception

        End Sub
    End Class

    <DataContract>
    Public Class DataTableDoesNotExistFault
        Inherits BaseFault

        Public Sub New(Name As String)
            MyBase.New()
            ErrorMessage = $"Datatable {Name} does not exist"
            IsRecoverable = True
            InnerException = Nothing
        End Sub
    End Class

    <DataContract>
    Public Class ObjectDoesNotExistFault
        Inherits BaseFault

        Public Sub New(ObjectId As Long)
            MyBase.New()
            ErrorMessage = $"Object with Id {ObjectId} does not exist"
            IsRecoverable = True
            InnerException = Nothing
        End Sub
    End Class

End Namespace
