DeveelDB  20151217
complete SQL database system, primarly developed for .NET/Mono frameworks
TriggerException.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.Sql.Triggers {
21  public TriggerException(Trigger trigger, Exception innerException)
22  : this(trigger, FormMessage(trigger), innerException) {
23  }
24 
25  public TriggerException(Trigger trigger, string message, Exception innerException)
26  : base(-1, message, innerException) {
27  TableName = trigger.TriggerInfo.TableName;
28  TriggerName = trigger.TriggerName;
29  EventType = trigger.TriggerInfo.EventType;
30  }
31 
32  public TriggerException(Trigger trigger)
33  : this(trigger, FormMessage(trigger)) {
34  }
35 
36  public TriggerException(Trigger trigger, string message)
37  : this(trigger, message, null) {
38  }
39 
40  public ObjectName TableName { get; private set; }
41 
42  public ObjectName TriggerName { get; private set; }
43 
44  public TriggerEventType EventType { get; private set; }
45 
46  private static string FormMessage(Trigger trigger) {
47  return FormMessage(trigger.TriggerInfo.TableName, trigger.TriggerName, trigger.TriggerInfo.EventType);
48  }
49 
50  private static string FormMessage(ObjectName tableName, ObjectName triggerName, TriggerEventType eventType) {
51  return String.Format("An error occurred when firing trigger '{0}' on table '{1}' on {2}",
52  triggerName, tableName, eventType.AsString());
53  }
54  }
55 }
TriggerEventType
The different types of high layer trigger events.
Describes the name of an object within a database.
Definition: ObjectName.cs:44
TriggerException(Trigger trigger, Exception innerException)
TriggerException(Trigger trigger, string message, Exception innerException)
TriggerEventType EventType
Gets the modification event on the attached table at which to fire the trigger.
Definition: TriggerInfo.cs:84
TriggerException(Trigger trigger, string message)
TriggerInfo TriggerInfo
Gets the information describing the dynamics of this trigger.
Definition: Trigger.cs:57
ObjectName TableName
Gets the fully qualified name of the database table on which to attach the trigger.
Definition: TriggerInfo.cs:96
Represents an event fired at a given modification event (either INSERT, DELETE or UPDATE) at a given ...
Definition: Trigger.cs:38
static string FormMessage(Trigger trigger)
ObjectName TriggerName
Gets the fully qualified name of the trigger, as defined in TriggerInfo
Definition: Trigger.cs:64
static string FormMessage(ObjectName tableName, ObjectName triggerName, TriggerEventType eventType)