DeveelDB  20151217
complete SQL database system, primarly developed for .NET/Mono frameworks
ErrorException.cs
Go to the documentation of this file.
1 //
2 // Copyright 2010-2015 Deveel
3 //
4 // Licensed under the Apache License, Version 2.0 (the "License");
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 // http://www.apache.org/licenses/LICENSE-2.0
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 //
16 
17 using System;
18 
19 namespace Deveel.Data.Diagnostics {
24  public class ErrorException : Exception {
25  public ErrorException(int errorCode)
26  : this(errorCode, null) {
27  }
28 
29  public ErrorException(int errorCode, string message)
30  : this(errorCode, message, null) {
31  }
32 
33  public ErrorException()
34  : this(null) {
35  }
36 
37  public ErrorException(string message)
38  : this(message, null) {
39  }
40 
41  public ErrorException(string message, Exception innerException)
42  : this(SystemErrorCodes.Unknown, message, innerException) {
43  }
44 
45  public ErrorException(int errorCode, string message, Exception innerException)
46  : base(message, innerException) {
47  ErrorCode = errorCode;
48  }
49 
54  public int ErrorCode { get; private set; }
55 
59  protected virtual ErrorLevel ErrorLevel {
60  get { return ErrorLevel.Error; }
61  }
62 
72  public ErrorEvent AsEvent(IEventSource source) {
73  var e = new ErrorEvent(this, ErrorCode, ErrorLevel);
74 
75  if (source != null)
76  e.EventSource = source;
77 
78  return e;
79  }
80  }
81 }
ErrorEvent AsEvent(IEventSource source)
Transforms the error to an event to be passed to the diagnostics, given a source where this was gener...
ErrorException(int errorCode, string message, Exception innerException)
ErrorLevel
In case of error messages, this enumerates the level of severity of the error.
Definition: ErrorLevel.cs:24
ErrorException(int errorCode, string message)
ErrorException(string message, Exception innerException)
Represents the origin of system events, providing a mechanism to fill the metadata before dispatching...
Definition: IEventSource.cs:40
The base class of all the exceptions handled by the system and that can be converted to events sent t...