MBExpressionError Class Reference

Inherits from NSObject
Declared in MBExpressionError.h

Overview

Represents errors that can occur during MBExpression parsing and evaluation.

Properties

  message

Returns a message explaining the error.

@property (nullable, nonatomic, readonly) NSString *message

Declared In

MBExpressionError.h

  causedByError

If the receiver was caused by an underlying NSError, this property will contain the original error. Otherwise, nil.

@property (nullable, nonatomic, readonly) NSError *causedByError

Declared In

MBExpressionError.h

  causedByException

If the receiver was caused by an underlying NSException, this property will contain the original exception. Otherwise, nil.

@property (nullable, nonatomic, readonly) NSException *causedByException

Declared In

MBExpressionError.h

  additionalErrors

Returns an array of MBExpressionErrors related to the receiver. May be nil.

@property (nullable, nonatomic, readonly) NSArray *additionalErrors

Declared In

MBExpressionError.h

  value

Stores an arbitrary value related to the error.

@property (nullable, nonatomic, strong) id value

Declared In

MBExpressionError.h

  offendingExpression

Stores a reference to the MBML expression in which the error occurred.

@property (nullable, nonatomic, strong) NSString *offendingExpression

Declared In

MBExpressionError.h

  offendingToken

Stores a reference to an MBMLParseToken involved in the error, which is useful for pinpointing the problematic portion of the offendingExpression.

@property (nullable, nonatomic, strong) MBMLParseToken *offendingToken

Declared In

MBExpressionError.h

Creating instances

+ errorWithMessage:

Creates a new MBExpressionError instance containing the specified message.

+ (nonnull instancetype)errorWithMessage:(nonnull NSString *)msg

Parameters

msg

The error message.

Return Value

A new MBExpressionError.

Declared In

MBExpressionError.h

+ errorWithMessage:error:

Creates a new MBExpressionError instance to represent an underlying NSError.

+ (nonnull instancetype)errorWithMessage:(nonnull NSString *)msg error:(nullable NSError *)nsErr

Parameters

msg

The error message.

nsErr

The NSError instance.

Return Value

A new MBExpressionError.

Declared In

MBExpressionError.h

+ errorWithMessage:exception:

Creates a new MBExpressionError instance to represent an underlying NSException.

+ (nonnull instancetype)errorWithMessage:(nonnull NSString *)msg exception:(nullable NSException *)ex

Parameters

msg

The error message.

ex

The NSException instance.

Return Value

A new MBExpressionError.

Declared In

MBExpressionError.h

+ errorWithFormat:

Creates a new MBExpressionError instance containing a message constructed from the specified format string and parameters.

+ (nonnull instancetype)errorWithFormat:(nonnull NSString *)format, ...

Parameters

format

The format for the error message, followed by zero or more format parameters.

...

A variable argument list of zero or more values referenced within the format string.

Return Value

A new MBExpressionError.

Declared In

MBExpressionError.h

+ errorWithError:

Creates a new MBExpressionError instance to represent an underlying NSError.

+ (nonnull instancetype)errorWithError:(nonnull NSError *)nsErr

Parameters

nsErr

The NSError instance.

Return Value

A new MBExpressionError.

Declared In

MBExpressionError.h

+ errorWithException:

Creates a new MBExpressionError instance to represent an underlying NSException.

+ (nonnull instancetype)errorWithException:(nonnull NSException *)ex

Parameters

ex

The NSException instance.

Return Value

A new MBExpressionError.

Declared In

MBExpressionError.h

Error logging

– logOutput

Returns a string containing the output that would be written to the console if log were to be called.

- (nonnull NSString *)logOutput

Return Value

The log output.

Declared In

MBExpressionError.h

– log

Logs the error to the console.

- (void)log

Declared In

MBExpressionError.h

Reporting errors

– reportErrorTo:

Reports the receiving error. The behavior of reporting depends on the contents of the reportTo parameter:

- (void)reportErrorTo:(MBExpressionErrorPtrPtr)reportTo

Parameters

reportTo

Determines where the receiver will be reported.

Discussion

  • If reportTo is nil, the receiver will be logged to the console using the log method.

  • If reportTo is non-nil but *reportTo is nil, the memory location pointed to by *reportTo will be updated to contain the receiver.

  • If reportTo is a non-nil pointer to an MBExpressionError instance the receiver will be reported to that error, meaning the receiver becomes its lastErrorReported.

Declared In

MBExpressionError.h

– reportErrorTo:suppressLog:

Reports the receiving error. The behavior of reporting depends on the contents of the reportTo parameter:

- (void)reportErrorTo:(MBExpressionErrorPtrPtr)reportTo suppressLog:(BOOL)suppressLog

Parameters

reportTo

Determines where the receiver will be reported.

suppressLog

If YES, calling this method will not result in a message being logged to the console.

Discussion

  • If reportTo is nil and suppressLog is NO, the receiver will be logged to the console using the log method.

  • If reportTo is non-nil but *reportTo is nil, the memory location pointed to by *reportTo will be updated to contain the receiver.

  • If reportTo is a non-nil pointer to an MBExpressionError instance the receiver will be reported to that error, meaning the receiver becomes its lastErrorReported.

Declared In

MBExpressionError.h

Checking for additional errors

– errorReported

Determines if an error has been reported since the last time the clearErrorReported method was called.

- (BOOL)errorReported

Return Value

YES if an error has been reported, NO otherwise.

Discussion

Note that this flag starts out as YES when new object instances are created.

Declared In

MBExpressionError.h

– clearErrorReported

Clears the flag returned by errorReported so that subsequent calls to errorReported return NO until the next time the receiver’s reportErrorTo method is called.

- (void)clearErrorReported

Declared In

MBExpressionError.h

– lastErrorReported

Returns the MBExpressionError most recently reported to the receiver, or nil if there isn’t one.

- (nullable MBExpressionError *)lastErrorReported

Return Value

The most recently reported error.

Discussion

Note: Calling the clearErrorReported method does not affect the return value of this method.

Declared In

MBExpressionError.h