Browse Source

IPS-9 Eliminate CC from names

IPS-9
Dirk Zimmermann 3 months ago
parent
commit
f4c4c99d84
3 changed files with 20 additions and 20 deletions
  1. +3
    -3
      xcode/PEPSCTPTransport/PEPSCTPTransport/Error/NSError+PEPSCTPTransport+internal.h
  2. +3
    -3
      xcode/PEPSCTPTransport/PEPSCTPTransport/Error/NSError+PEPSCTPTransport.h
  3. +14
    -14
      xcode/PEPSCTPTransport/PEPSCTPTransport/Error/NSError+PEPSCTPTransport.m

+ 3
- 3
xcode/PEPSCTPTransport/PEPSCTPTransport/Error/NSError+PEPSCTPTransport+internal.h View File

@ -31,14 +31,14 @@ NS_ASSUME_NONNULL_BEGIN
/// Figures out whether or not a given status code is indicating an error condition.
/// @param statusCode status code to check if it's considered an error
/// @return YES if the status code is considered an error, NO otherwize.
+ (BOOL)isErrorCCTransportStatusCode:(PEPTransportStatusCode)statusCode;
+ (BOOL)isErrorTransportStatusCode:(PEPTransportStatusCode)statusCode;
/// Figures out whether or not a given status indicates an error condition and returns an NSError object
/// representing the error if so.
/// @param statusCode status code to create NSError from
/// @return NSError representing the error status code if the status code is considered an error,
/// nil otherwize.
+ (NSError * _Nullable)errorWithPEPCCTransportStatusCode:(PEPTransportStatusCode)statusCode;
+ (NSError * _Nullable)errorWithPEPTransportStatusCode:(PEPTransportStatusCode)statusCode;
/// If the status indicates an error condition, the given [NS]error is updated to represent the
/// error status.
@ -54,7 +54,7 @@ NS_ASSUME_NONNULL_BEGIN
/// @param error error to update according to status code
/// @param statusCode status code to update error with
/// @return YES if the error object was updated, NO otherwise.
+ (BOOL)setError:(NSError * _Nullable * _Nullable)error fromPEPCCStatusCode:(PEPTransportStatusCode)statusCode;
+ (BOOL)setError:(NSError * _Nullable * _Nullable)error fromPEPStatusCode:(PEPTransportStatusCode)statusCode;
@end


+ 3
- 3
xcode/PEPSCTPTransport/PEPSCTPTransport/Error/NSError+PEPSCTPTransport.h View File

@ -10,13 +10,13 @@
NS_ASSUME_NONNULL_BEGIN
/// Domain for errors indicated by the pEp engine.
extern NSString *const _Nonnull PEPCCEngineStatusErrorDomain;
extern NSString *const _Nonnull PEPEngineStatusErrorDomain;
/// Domain for errors indicated by the SCTP transport (see transport.h)
extern NSString *const _Nonnull PEPCCTransportStatusStatusErrorDomain;
extern NSString *const _Nonnull PEPTransportStatusStatusErrorDomain;
/// Domain for errors indicated by the PEPCC itself.
extern NSString *const _Nonnull PEPCCErrorDomain;
extern NSString *const _Nonnull PEPErrorDomain;
/**
Extension for creating `NSError`s from `PEP_STATUS`


+ 14
- 14
xcode/PEPSCTPTransport/PEPSCTPTransport/Error/NSError+PEPSCTPTransport.m View File

@ -9,9 +9,9 @@
#import "NSError+PEPSCTPTransport+internal.h"
#import "NSError+PEPStatus.h"
NSString *const _Nonnull PEPCCEngineStatusErrorDomain = @"PEPCCEngineStatusErrorDomain";
NSString *const _Nonnull PEPCCTransportStatusStatusErrorDomain = @"PEPCCTransportStatusStatusErrorDomain";
NSString *const _Nonnull PEPCCErrorDomain = @"PEPCCErrorDomain";
NSString *const _Nonnull PEPEngineStatusErrorDomain = @"PEPCCEngineStatusErrorDomain";
NSString *const _Nonnull PEPTransportStatusStatusErrorDomain = @"PEPCCTransportStatusStatusErrorDomain";
NSString *const _Nonnull PEPErrorDomain = @"PEPCCErrorDomain";
@implementation NSError (PEPSCTPTransport)
@ -37,7 +37,7 @@ NSString *const _Nonnull PEPCCErrorDomain = @"PEPCCErrorDomain";
NSDictionary *dict = [NSDictionary
dictionaryWithObjectsAndKeys:localizedErrorStringFromPEPStatus(status),
NSLocalizedDescriptionKey, nil];
return [NSError errorWithDomain:PEPCCEngineStatusErrorDomain
return [NSError errorWithDomain:PEPEngineStatusErrorDomain
code:status
userInfo:dict];
} else {
@ -45,7 +45,7 @@ NSString *const _Nonnull PEPCCErrorDomain = @"PEPCCErrorDomain";
}
}
+ (BOOL)isErrorCCTransportStatusCode:(PEPTransportStatusCode)statusCode {
+ (BOOL)isErrorTransportStatusCode:(PEPTransportStatusCode)statusCode {
switch (statusCode) {
// Status that are not an error
case PEPTransportStatusCodeReady:
@ -63,14 +63,14 @@ NSString *const _Nonnull PEPCCErrorDomain = @"PEPCCErrorDomain";
}
}
+ (NSError * _Nullable)errorWithPEPCCTransportStatusCode:(PEPTransportStatusCode)statusCode
+ (NSError * _Nullable)errorWithPEPTransportStatusCode:(PEPTransportStatusCode)statusCode
{
if ([self isErrorCCTransportStatusCode:statusCode]) {
NSDictionary *dict = [NSDictionary
dictionaryWithObjectsAndKeys:localizedErrorStringFromPEPCCTransportStatusCode(statusCode),
dictionaryWithObjectsAndKeys:localizedErrorStringFromPEPTransportStatusCode(statusCode),
NSLocalizedDescriptionKey, nil];
return [NSError
errorWithDomain:PEPCCTransportStatusStatusErrorDomain
errorWithDomain:PEPTransportStatusStatusErrorDomain
code:statusCode
userInfo:dict];
} else {
@ -96,10 +96,10 @@ NSString *const _Nonnull PEPCCErrorDomain = @"PEPCCErrorDomain";
}
}
+ (BOOL)setError:(NSError * _Nullable * _Nullable)error fromPEPCCStatusCode:(PEPTransportStatusCode)statusCode
+ (BOOL)setError:(NSError * _Nullable * _Nullable)error fromPEPStatusCode:(PEPTransportStatusCode)statusCode
{
// Determine if the given status is an error.
NSError *errorFromStatusCode = [self errorWithPEPCCTransportStatusCode:statusCode];
NSError *errorFromStatusCode = [self errorWithPEPTransportStatusCode:statusCode];
// Set caller's error, if given
if (error) {
@ -111,17 +111,17 @@ NSString *const _Nonnull PEPCCErrorDomain = @"PEPCCErrorDomain";
}
/// Could in theory return a fully localized version of the underlying error.
NSString * _Nonnull localizedErrorStringFromPEPCCTransportStatusCode(PEPTransportStatusCode status) {
return stringFromPEPCCTransportStatusCode(status);
NSString * _Nonnull localizedErrorStringFromPEPTransportStatusCode(PEPTransportStatusCode status) {
return stringFromPEPTransportStatusCode(status);
}
NSString * _Nonnull stringFromPEPCCTransportStatusCode(PEPTransportStatusCode status) {
NSString * _Nonnull stringFromPEPTransportStatusCode(PEPTransportStatusCode status) {
return [NSString stringWithFormat:@"PEPCCTransportStatusCode: %ld", (long)status];
}
- (NSString * _Nullable)pEpErrorString
{
if ([self.domain isEqualToString:PEPCCEngineStatusErrorDomain]) {
if ([self.domain isEqualToString:PEPEngineStatusErrorDomain]) {
return stringFromPEPStatus((PEP_STATUS) self.code);
} else {
return nil;


Loading…
Cancel
Save