NSError(MBToolbox) Category Reference

Declared in NSError+MBToolbox.h

Overview

An NSError class extension that provides Mockingbird-specific functionality.

Creating errors in the Mockingbird error domain

+ mockingbirdErrorWithCode:

Constructs a new NSError instance in the error domain specified by the kMBErrorDomain constant.

+ (nonnull NSError *)mockingbirdErrorWithCode:(NSInteger)code

Parameters

code

The error code.

Return Value

A new NSError instance with the specified settings.

Declared In

NSError+MBToolbox.h

+ mockingbirdErrorWithCode:userInfo:

Constructs a new NSError instance in the error domain specified by the kMBErrorDomain constant.

+ (nonnull NSError *)mockingbirdErrorWithCode:(NSInteger)code userInfo:(nullable NSDictionary *)dict

Parameters

code

The error code.

dict

The user info dictionary for the returned error.

Return Value

A new NSError instance with the specified settings.

Declared In

NSError+MBToolbox.h

+ mockingbirdErrorWithCode:userInfoKey:value:

Constructs a new NSError instance in the error domain specified by the kMBErrorDomain constant.

+ (nonnull NSError *)mockingbirdErrorWithCode:(NSInteger)code userInfoKey:(nonnull NSString *)key value:(nonnull id)val

Parameters

code

The error code.

key

The key whose corresponding value will be stored in the returned error’s user info dictionary.

val

The value that will be associated with key.

Return Value

A new NSError instance with the specified settings.

Discussion

The error’s user info dictionary will contain the specified key and value.

Declared In

NSError+MBToolbox.h

+ mockingbirdErrorWithDescription:

Constructs a new NSError instance in the error domain specified by the kMBErrorDomain constant.

+ (nonnull NSError *)mockingbirdErrorWithDescription:(nonnull NSString *)desc

Parameters

desc

The description of the error, which will be available through the user info key NSLocalizedDescriptionKey as well as the error’s localizedDescription method.

Return Value

A new NSError instance with the specified settings.

Discussion

The error’s code will be kMBErrorMessageInDescription.

Declared In

NSError+MBToolbox.h

+ mockingbirdErrorWithDescription:code:

Constructs a new NSError instance in the error domain specified by the kMBErrorDomain constant.

+ (nonnull NSError *)mockingbirdErrorWithDescription:(nonnull NSString *)desc code:(NSInteger)code

Parameters

desc

The description of the error, which will be available through the user info key NSLocalizedDescriptionKey as well as the error’s localizedDescription method.

code

The error code.

Return Value

A new NSError instance with the specified settings.

Declared In

NSError+MBToolbox.h

+ mockingbirdErrorWithDescription:code:userInfoKey:value:

Constructs a new NSError instance in the error domain specified by the kMBErrorDomain constant.

+ (nonnull NSError *)mockingbirdErrorWithDescription:(nonnull NSString *)desc code:(NSInteger)code userInfoKey:(nonnull NSString *)key value:(nonnull id)val

Parameters

desc

The description of the error, which will be available through the user info key NSLocalizedDescriptionKey as well as the error’s localizedDescription method.

code

The error code.

key

The key whose corresponding value will be stored in the returned error’s user info dictionary.

val

The value that will be associated with key.

Return Value

A new NSError instance with the specified settings.

Discussion

The error’s user info dictionary will contain the specified key and value.

Declared In

NSError+MBToolbox.h

+ mockingbirdErrorWithException:

Constructs a new NSError instance in the error domain specified by the kMBErrorDomain constant.

+ (nonnull NSError *)mockingbirdErrorWithException:(nonnull NSException *)ex

Parameters

ex

The NSException to wrap in the returned error.

Return Value

A new NSError instance with the specified settings.

Discussion

The error will encapsulate the passed-in exception.

Declared In

NSError+MBToolbox.h

Creating derived errors

– errorByAddingOrRemovingUserInfoKey:value:

Creates and returns a new NSError instance based on the receiver by adding or removing the user info dictionary value for the given key.

- (nonnull NSError *)errorByAddingOrRemovingUserInfoKey:(nonnull NSString *)key value:(nullable id)val

Parameters

key

The key whose corresponding value will be stored in the returned error’s user info dictionary.

val

The value that will be associated with key. If nil, any existing value for key will be removed instead.

Return Value

A new NSError instance with the same settings as the receiver, but with the specified user info value added.

Declared In

NSError+MBToolbox.h