MoEngageRequestFailure
@objc(MoEngageRequestFailure)
public class MoEngageRequestFailure : NSError, @unchecked Sendable
Failure delivered to MoEngageTaskProtocol.onFailure and thrown from
MoEngageTaskProtocol.result(). Wraps a MoEngageRequestFailureReason, a
human-readable message, and an optional underlying cause. NSError subclass
for ObjC bridging.
Supports NSSecureCoding. On decode, the reason is reconstructed as the base
MoEngageRequestFailureReason carrying the shared code — module-specific
subclass metadata is dropped. When decoding chained failures, include both
NSError.self and MoEngageRequestFailure.self in the unarchiver’s allow-list.
-
Error domain used by every
MoEngageRequestFailure.Declaration
Swift
@objc public static let errorDomain: String -
Reason describing the failure (shared code or module-specific subclass).
Declaration
Swift
@objc public let reason: MoEngageRequestFailureReason -
Human-readable failure message.
Declaration
Swift
@objc public let message: String -
Optional underlying cause (e.g. an
NSErrorfrom the network layer).Declaration
Swift
@objc public let cause: NSError? -
Create a failure wrapping a reason, message, and optional cause.
Declaration
Swift
@objc public init(reason: MoEngageRequestFailureReason, message: String = "", cause: NSError? = nil)Parameters
reasonThe reason describing the failure.
messageA human-readable failure message.
causeOptional underlying
NSErrorcarrying additional context.
-
Declaration
Swift
public override class var supportsSecureCoding: Bool { get }
-
Declaration
Swift
public required init?(coder: NSCoder) -
Declaration
Swift
public override func encode(with coder: NSCoder) -
Declaration
Swift
public override var description: String { get }
-
Build the standard
.sdkNotInitializedfailure for the supplied workspace.nilworkspaceId renders as<default>in the message.Declaration
Swift
static func sdkNotInitialized(workspaceId: String?) -> MoEngageRequestFailure -
Build a
.featureDisabledfailure with a caller-provided message — lets callers differentiate analytics-disabled / opted-out / blacklisted without inventing module-specific codes.Declaration
Swift
static func featureDisabled(_ message: String) -> MoEngageRequestFailure -
Returns a
.featureDisabledrejection if data tracking is disabled or the user is opted out, otherwisenil. Centralises the two-toggle guard so typed-task public APIs surface a consistent failure when the SDK can do nothing.Declaration
Swift
static func dataTrackingDisabledFailure( forInstance sdkInstance: isolated MoEngageSDKInstance = #isolation ) -> MoEngageRequestFailure?