TICDSError Class Reference
Inherits from | NSError |
Declared in | TICDSError.h |
Overview
TICDSError
is a utility class to generate NSError
objects with certain characteristics.
Any error generated by one of the calls to TICDSError
will be an instance of TICDSError
. The only difference between NSError
and TICDSError
is that it overrides the description
method to show the entire contents of the error’s userInfo
dictionary.
TICDSError
can optionally include a stack trace in every error object it generates. Call [TICDSError setIncludeStackTraceInErrors:]
and pass YES
before generating any errors to enable this option. Obviously, because of the way these are generated, the stack trace will include the methods used to generate the error.
With includesStackTraceInErrors
turned on, examining an error using NSLog(@"%@", someError)
will display output similar to the following:
Error Domain=com.timisted.ticoredatasync Code=2 UserInfo=0x10064f1a0 "File Manager error"
User Info:{
NSLocalizedDescription = "File Manager error";
kTICDSErrorClassAndMethod = "[TICDSFileManagerBasedVacuumOperation findOutLeastRecentClientSyncDate]";
NSUnderlyingErrorKey = "Error Domain=NSCocoaErrorDomain Code=256 UserInfo=0x100649400 \"The file couldn\U2019t be opened.\" Underlying Error=(Error Domain=NSOSStatusErrorDomain Code=-2111 \"The operation couldn\U2019t be completed. (OSStatus error -2111.)\")";
kTICDSStackTrace = (
"0 ShoppingListMac 0x000000010000b08e [TICDSError errorWithCode:underlyingError:userInfo:classAndMethod:] + 590",
"1 ShoppingListMac 0x000000010000ae38 [TICDSError errorWithCode:underlyingError:classAndMethod:] + 72",
"2 ShoppingListMac 0x000000010003ae46 [TICDSFileManagerBasedVacuumOperation findOutLeastRecentClientSyncDate] + 310",
"3 ShoppingListMac 0x000000010003a203 [TICDSVacuumOperation beginFindingOutLeastRecentClientSyncDate] + 211",
"4 ShoppingListMac 0x000000010003a126 [TICDSVacuumOperation main] + 54",
"5 ShoppingListMac 0x000000010000b410 [TICDSOperation start] + 368",
"6 Foundation 0x00007fff80138ae7 __doStart2 + 97",
"7 libSystem.B.dylib 0x00007fff84fdb284 _dispatch_call_block_and_release + 15",
"8 libSystem.B.dylib 0x00007fff84fb97f1 _dispatch_worker_thread2 + 239",
"9 libSystem.B.dylib 0x00007fff84fb9128 _pthread_wqthread + 353",
"10 libSystem.B.dylib 0x00007fff84fb8fc5 start_wqthread + 13"
);
}
Tasks
Error Generation
-
+ errorWithCode:userInfo:
Generate an error with the given code.
-
+ errorWithCode:classAndMethod:
Generate an error with the given code in a specific class and method.
-
+ errorWithCode:underlyingError:classAndMethod:
Generate an error with the given code and another underlying error in a specific class and method.
-
+ errorWithCode:underlyingError:userInfo:classAndMethod:
Generate an error with the given code and another underlying error in a specific class and method, also providing your own user info.
Error Stack Trace Logging
-
+ setIncludeStackTraceInErrors:
Specify whether to include a stack trace in errors generated by
TICDSError
class factory methods. -
+ includeStackTraceInErrors
Indicates whether a stack trace will be included in errors generated by
TICDSError
class factory methods.
Class Methods
errorWithCode:classAndMethod:
Generate an error with the given code in a specific class and method.
+ (NSError *)errorWithCode:(TICDSErrorCode)aCode classAndMethod:(const char *)aClassAndMethod
Parameters
- aCode
The error code to use.
- aClassAndMethod
A C-string, typically provided by
__PRETTY_FUNCTION__
.
Return Value
A properly-configured NSError
object with the class and method specified in the user info.
Declared In
TICDSError.h
errorWithCode:underlyingError:classAndMethod:
Generate an error with the given code and another underlying error in a specific class and method.
+ (NSError *)errorWithCode:(TICDSErrorCode)aCode underlyingError:(NSError *)anUnderlyingError classAndMethod:(const char *)aClassAndMethod
Parameters
- aCode
The error code to use.
- anUnderlyingError
The underlying
NSError
that caused this particularTICoreDataSync
error.
- aClassAndMethod
A C-string, typically provided by
__PRETTY_FUNCTION__
.
Return Value
A properly-configured NSError
object, with the underlying error, and class and method specified in the user info.
Declared In
TICDSError.h
errorWithCode:underlyingError:userInfo:classAndMethod:
Generate an error with the given code and another underlying error in a specific class and method, also providing your own user info.
+ (NSError *)errorWithCode:(TICDSErrorCode)aCode underlyingError:(NSError *)anUnderlyingError userInfo:(id)someInfo classAndMethod:(const char *)aClassAndMethod
Parameters
- aCode
The error code to use.
- anUnderlyingError
The underlying
NSError
that caused this particularTICoreDataSync
error.
- someInfo
The user info you wish to supply (in addition that created automatically) for this error.
- aClassAndMethod
A C-string, typically provided by
__PRETTY_FUNCTION__
.
Return Value
A properly-configured NSError
object, with the underlying error and class and method, specified in the user info, which will be merged with the provided someInfo
.
Declared In
TICDSError.h
errorWithCode:userInfo:
Generate an error with the given code.
+ (NSError *)errorWithCode:(TICDSErrorCode)aCode userInfo:(id)someInfo
Parameters
- aCode
The error code to use.
- someInfo
The user info to set on the
NSError
object.
Return Value
A properly-configured NSError
object.
Declared In
TICDSError.h