Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

55 lines (42 sloc) 1.404 kb
// NSException+GBException.m
// appledoc
// Created by Tomaz Kragelj on 23.7.10.
// Copyright (C) 2010, Gentle Bytes. All rights reserved.
#import "NSException+GBException.h"
@interface NSException (GBExceptionPrivate)
+ (NSString *)reasonWithError:(NSError *)error message:(NSString *)message;
#pragma mark -
@implementation NSException (GBException)
+ (void)raise:(NSString *)format, ... {
va_list args;
va_start(args, format);
[self raise:@"AppledocException" format:format arguments:args];
+ (void)raise:(NSError *)error format:(NSString *)format, ... {
NSString *message = nil;
if (format) {
va_list args;
va_start(args, format);
message = [[[NSString alloc] initWithFormat:format arguments:args] autorelease];
NSString *reason = [self reasonWithError:error message:message];
[self raise:reason];
+ (NSString *)reasonWithError:(NSError *)error message:(NSString *)message {
NSInteger code = [error code];
NSString *domain = [error domain];
NSString *description = [error localizedDescription];
NSString *reason = [error localizedFailureReason];
NSMutableString *result = [NSMutableString string];
if (message) [result appendFormat:@"%@\n", message];
[result appendFormat:@"Error: %@, code %i: %@\n", domain, code, description];
if (reason) [result appendFormat:@"Reason: %@", reason];
return result;
Jump to Line
Something went wrong with that request. Please try again.