/*!
  @header FTExceptions
  @abstract Module of FT
 
  @availability OS X, GNUstep
  @copyright 2004, 2005, 2006 Free Software Foundation, Inc.
  
  This library is free software; you can redistribute it and/or
  modify it under the terms of the GNU Lesser General Public
  License as published by the Free Software Foundation; either
  version 2.1 of the License, or (at your option) any later version.

  This library is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  Lesser General Public License for more details.

  You should have received a copy of the GNU Lesser General Public
  License along with this library; if not, write to the Free Software
  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301 USA

  <pre>
  -------------------------------------------------------------------------
  Modification history

  14.02.05 ola     initial version
  23.08.06 ola     license changed
  -------------------------------------------------------------------------
  </pre>
*/

#include <FT/FTExceptions.h>

@implementation FTException
@end


@implementation FTUnknownException

- init {
  self = [super init];
  self->contextInfo = nil;
  self->exception = nil;
  
  return self;
}


- initWithContextInfo: (NSString *) aContextInfo 
  exception: (NSException *) anException {
  self = [self init];
  self->contextInfo = [aContextInfo retain];
  self->exception = [anException retain];
  
  return self;
}


- (void) dealloc {
  if( nil != self->contextInfo ) {
    [self->contextInfo release];
  }
  
  if( nil != self->exception ) {
    [self->exception release];
  }
  
  [super dealloc];
}


- (NSString *) contextInfo {
  return self->contextInfo;
}


- (NSException *) exception {
  return self->exception;
}
@end


@implementation FTInternalDatamanagementException
- int {
  self = [super init];
  self->operationStatus = BDB_STATUS_UNKNOWN;
  self->bdbException = nil;
  
  return self;
}


- initWithOperationStatus: (BDBOperationStatus) status {
  self = [self init];
  self->operationStatus = status;
  
  return self;
}


- initWithBDBException: (BDBException *) anException {
  self = [self init];
  self->bdbException = [anException retain];
  
  return self;
}


- (void) dealloc {
  if( nil != self->bdbException ) {
    [self->bdbException release];
  }
  
  [super dealloc];
}


- (BDBException *) bdbException {
  return self->bdbException;
}


- (BDBOperationStatus) operationStatus {
  return self->operationStatus;
}
@end


@implementation FTDatabaseCreationFailedException

- initWithReason: (NSString *) aReason {
  self = [super init];
  self->theReason = [aReason retain];
  
  return self;
}


- (void) dealloc {
  [self->theReason release];
  [super dealloc];
}


- (NSString *) reason {
  return self->theReason;
}
@end


@implementation FTTransactionStepException 

- initWithTransactionStepException: (id) causingException {
  self = [super init];
  self->transactionStepException = [causingException retain];
  
  return self;
}


- (void) dealloc {
  if( nil != self->transactionStepException ) {
    [self->transactionStepException release];
  }
  
  [super dealloc];
}


- transactionStepException {
  return self->transactionStepException;
}
@end



@implementation FTDatabaseUpdateException
- initWithOperationStatus: (BDBOperationStatus) aStatus
  operationInformation: (NSString *) anInfo {
  self = [super initWithReason: anInfo];
  
  self->operationStatus = aStatus;
  self->operationInfo = [anInfo retain];
  
  return self;
}


- (void) dealloc {
  [self->operationInfo release];
  
  [super dealloc];
}


- (BDBOperationStatus) operationStatus {
  return self->operationStatus;
}


- (NSString *) operationInfo {
  return self->operationInfo;
}
@end


@implementation FTGraphRemoveException
- initWithGraphId: (id <FTId>) aGraphId withReason: (NSString *) aReason {
  self = [super initWithReason: aReason];
  self->graphId = [aGraphId retain];
  
  return self;
}


- (void) dealloc {
  [self->graphId release];
  
  [super dealloc];
}


- (id <FTId>) graphId {
  return self->graphId;
}
@end
