CSLA.NET 6.0.0
CSLA .NET is a software development framework that helps you build a reusable, maintainable object-oriented business layer for your app.
GenericBusinessException.cs
Go to the documentation of this file.
1#if !NETFX_CORE && !(ANDROID || IOS)
2//-----------------------------------------------------------------------
3// <copyright file="GenericBusinessException.cs" company="Marimer LLC">
4// Copyright (c) Marimer LLC. All rights reserved.
5// Website: https://cslanet.com
6// </copyright>
7// <summary>This exception is returned as BusinessException in DataPortalException when the </summary>
8//-----------------------------------------------------------------------
9using System;
10using System.Collections;
11using System.Runtime.Serialization;
12
13namespace Csla.Server
14{
19 [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1032:ImplementStandardExceptionConstructors")]
20 [Serializable()]
21 public class GenericBusinessException : Exception
22 {
23
24 private string _stackTrace;
25 private IDictionary _data;
26 private string _type;
27
36 public override string StackTrace
37 {
38 get
39 {
40 return _stackTrace;
41 }
42 }
43
49 public override IDictionary Data
50 {
51 get
52 {
53 return _data;
54 }
55 }
56
61 public string TypeName
62 {
63 get
64 {
65 return _type;
66 }
67 }
68
74 public GenericBusinessException(Exception wrappedException)
75 : base(wrappedException.Message)
76 {
77 this.Source = wrappedException.Source;
78 this.HelpLink = wrappedException.HelpLink;
79 _data = wrappedException.Data;
80 _stackTrace = wrappedException.StackTrace;
81 _type = wrappedException.GetType().ToString();
82 }
83
89 public GenericBusinessException(Exception wrappedException, Exception innerException)
90 : base(wrappedException.Message, innerException)
91 {
92 this.Source = wrappedException.Source;
93 this.HelpLink = wrappedException.HelpLink;
94 _data = wrappedException.Data;
95 _stackTrace = wrappedException.StackTrace;
96 _type = wrappedException.GetType().ToString();
97 }
98
99
107 public GenericBusinessException(SerializationInfo info, StreamingContext context)
108 : base(info, context)
109 {
110
111 _data = (IDictionary)info.GetValue("_data", typeof(IDictionary));
112 _stackTrace = info.GetString("_stackTrace");
113 _type = info.GetString("_type");
114 }
115
126 [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1062:ValidateArgumentsOfPublicMethods")]
127#if !NET5_0 && !NET6_0
128 [System.Security.Permissions.SecurityPermission(System.Security.Permissions.SecurityAction.LinkDemand, Flags = System.Security.Permissions.SecurityPermissionFlag.SerializationFormatter)]
129 [System.Security.Permissions.SecurityPermission(System.Security.Permissions.SecurityAction.Demand, Flags = System.Security.Permissions.SecurityPermissionFlag.SerializationFormatter)]
130#endif
131 public override void GetObjectData(SerializationInfo info, StreamingContext context)
132 {
133 base.GetObjectData(info, context);
134
135 info.AddValue("_data", _data);
136 info.AddValue("_stackTrace", _stackTrace);
137 info.AddValue("_type", _type);
138 }
139
149 public override string ToString()
150 {
151 string className;
152 string message = this.Message;
153 if ((message == null) || (message.Length <= 0))
154 {
155 className = _type;
156 }
157 else
158 {
159 className = _type + ": " + message;
160 }
161 string stackTrace = this.StackTrace;
162 if (stackTrace != null)
163 {
164 className = className + Environment.NewLine + stackTrace;
165 }
166 return className;
167 }
168 }
169}
170#endif
This exception is returned as BusinessException in DataPortalException when the serverside/inner exce...
override IDictionary Data
Gets a collection of key/value pairs that provide additional user-defined information about the excep...
GenericBusinessException(SerializationInfo info, StreamingContext context)
Initializes a new instance of the GenericBusinessException class.
override string ToString()
Returns a System.String that represents this instance.
override void GetObjectData(SerializationInfo info, StreamingContext context)
When overridden in a derived class, sets the T:System.Runtime.Serialization.SerializationInfo with in...
string TypeName
Gets the name of the type.
GenericBusinessException(Exception wrappedException, Exception innerException)
Initializes a new instance of the GenericBusinessException class.
GenericBusinessException(Exception wrappedException)
Initializes a new instance of the GenericBusinessException class.
override string StackTrace
Gets a string representation of the immediate frames on the call stack.
@ Serializable
Prevents updating or inserting until the transaction is complete.