Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions extension/apple/ExecuTorch/Exported/ExecuTorchError.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,4 +67,16 @@ __attribute__((deprecated("This API is experimental.")))
NSError *ExecuTorchErrorWithCode(ExecuTorchErrorCode code)
NS_SWIFT_NAME(Error(code:));

/**
* Create an NSError in the ExecuTorch domain for the given code.
*
* @param code The ExecuTorchErrorCode to wrap.
* @param description Additional error description.
* @return An NSError with ExecuTorchErrorDomain, the specified code, and a localized description.
*/
FOUNDATION_EXPORT
__attribute__((deprecated("This API is experimental.")))
NSError *ExecuTorchErrorWithCodeAndDescription(ExecuTorchErrorCode code, NSString * __nullable description)
NS_SWIFT_NAME(Error(code:description:));

NS_ASSUME_NONNULL_END
11 changes: 9 additions & 2 deletions extension/apple/ExecuTorch/Exported/ExecuTorchError.m
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,16 @@
}

NSError *ExecuTorchErrorWithCode(ExecuTorchErrorCode code) {
return ExecuTorchErrorWithCodeAndDescription(code, nil);
}

NSError *ExecuTorchErrorWithCodeAndDescription(ExecuTorchErrorCode code, NSString * __nullable description) {
return [NSError errorWithDomain:ExecuTorchErrorDomain
code:code
userInfo:@{
NSLocalizedDescriptionKey : ExecuTorchErrorDescription(code)
}];
NSLocalizedDescriptionKey:
description.length > 0
? [ExecuTorchErrorDescription(code) stringByAppendingFormat:@": %@", description]
: ExecuTorchErrorDescription(code)
}];
}
Loading