diff --git a/FirebaseCore/Sources/FIRApp.m b/FirebaseCore/Sources/FIRApp.m index 3f481ab5066..8cd3c229bfa 100644 --- a/FirebaseCore/Sources/FIRApp.m +++ b/FirebaseCore/Sources/FIRApp.m @@ -90,6 +90,11 @@ NSString *const FIRAuthStateDidChangeInternalNotificationUIDKey = @"FIRAuthStateDidChangeInternalNotificationUIDKey"; +/** + * Error domain for exceptions and NSError construction. + */ +NSString *const kFirebaseCoreErrorDomain = @"com.firebase.core"; + /** * The URL to download plist files. */ @@ -479,20 +484,7 @@ + (NSError *)errorForMissingOptions { NSLocalizedRecoverySuggestionErrorKey : @"Check formatting and location of GoogleService-Info.plist." }; - return [NSError errorWithDomain:kFirebaseCoreErrorDomain - code:FIRErrorCodeInvalidPlistFile - userInfo:errorDict]; -} - -+ (NSError *)errorForSubspecConfigurationFailureWithDomain:(NSString *)domain - errorCode:(FIRErrorCode)code - service:(NSString *)service - reason:(NSString *)reason { - NSString *description = - [NSString stringWithFormat:@"Configuration failed for service %@.", service]; - NSDictionary *errorDict = - @{NSLocalizedDescriptionKey : description, NSLocalizedFailureReasonErrorKey : reason}; - return [NSError errorWithDomain:domain code:code userInfo:errorDict]; + return [NSError errorWithDomain:kFirebaseCoreErrorDomain code:-100 userInfo:errorDict]; } + (NSError *)errorForInvalidAppID { @@ -502,9 +494,7 @@ + (NSError *)errorForInvalidAppID { @"Check formatting and location of GoogleService-Info.plist or GoogleAppID set in the " @"customized options." }; - return [NSError errorWithDomain:kFirebaseCoreErrorDomain - code:FIRErrorCodeInvalidAppID - userInfo:errorDict]; + return [NSError errorWithDomain:kFirebaseCoreErrorDomain code:-101 userInfo:errorDict]; } + (BOOL)isDefaultAppConfigured { diff --git a/FirebaseCore/Sources/FIRErrors.m b/FirebaseCore/Sources/FIRErrors.m deleted file mode 100644 index 104eeb82527..00000000000 --- a/FirebaseCore/Sources/FIRErrors.m +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright 2017 Google -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#import "FirebaseCore/Sources/Private/FIRErrors.h" - -NSString *const kFirebaseErrorDomain = @"com.firebase"; -NSString *const kFirebaseConfigErrorDomain = @"com.firebase.config"; -NSString *const kFirebaseCoreErrorDomain = @"com.firebase.core"; -NSString *const kFirebasePerfErrorDomain = @"com.firebase.perf"; -NSString *const kFirebaseStorageErrorDomain = @"com.firebase.storage"; diff --git a/FirebaseCore/Sources/Private/FIRAppInternal.h b/FirebaseCore/Sources/Private/FIRAppInternal.h index 599a85fca66..bf0ad4f37fc 100644 --- a/FirebaseCore/Sources/Private/FIRAppInternal.h +++ b/FirebaseCore/Sources/Private/FIRAppInternal.h @@ -16,13 +16,6 @@ #import -// The has_include is a workaround so the old IID needed for the FIS tests can find FIRErrors.h -#if __has_include("FirebaseCore/Sources/Private/FIRErrors.h") -#import "FirebaseCore/Sources/Private/FIRErrors.h" -#else -#import -#endif - @class FIRComponentContainer; @protocol FIRLibrary; @@ -46,6 +39,7 @@ extern NSString *const kFIRAppDeleteNotification; extern NSString *const kFIRAppIsDefaultAppKey; extern NSString *const kFIRAppNameKey; extern NSString *const kFIRGoogleAppIDKey; +extern NSString *const kFirebaseCoreErrorDomain; /** * The format string for the User Defaults key used for storing the data collection enabled flag. @@ -105,14 +99,6 @@ extern NSString *const FIRAuthStateDidChangeInternalNotificationUIDKey; */ @property(nonatomic) FIRComponentContainer *container; -/** - * Creates an error for failing to configure a subspec service. This method is called by each - * FIRApp notification listener. - */ -+ (NSError *)errorForSubspecConfigurationFailureWithDomain:(NSString *)domain - errorCode:(FIRErrorCode)code - service:(NSString *)service - reason:(NSString *)reason; /** * Checks if the default app is configured without trying to configure it. */ diff --git a/FirebaseCore/Sources/Private/FIRErrorCode.h b/FirebaseCore/Sources/Private/FIRErrorCode.h deleted file mode 100644 index c90d9eecf54..00000000000 --- a/FirebaseCore/Sources/Private/FIRErrorCode.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright 2017 Google - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** Error codes in Firebase error domain. */ -typedef NS_ENUM(NSInteger, FIRErrorCode) { - /** - * Unknown error. - */ - FIRErrorCodeUnknown = 0, - /** - * Loading data from the GoogleService-Info.plist file failed. This is a fatal error and should - * not be ignored. Further calls to the API will fail and/or possibly cause crashes. - */ - FIRErrorCodeInvalidPlistFile = -100, - - /** - * Validating the Google App ID format failed. - */ - FIRErrorCodeInvalidAppID = -101, - - /** - * Error code for failing to configure a specific service. It's deprecated, but - * still used after copybara. - */ - FIRErrorCodeConfigFailed = -114, -}; diff --git a/FirebaseCore/Sources/Private/FIRErrors.h b/FirebaseCore/Sources/Private/FIRErrors.h deleted file mode 100644 index 19e47328ace..00000000000 --- a/FirebaseCore/Sources/Private/FIRErrors.h +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Copyright 2017 Google - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#import - -#include "FIRErrorCode.h" - -extern NSString *const kFirebaseErrorDomain; -extern NSString *const kFirebaseConfigErrorDomain; -extern NSString *const kFirebaseCoreErrorDomain; -extern NSString *const kFirebasePerfErrorDomain; diff --git a/FirebaseCore/Tests/SwiftUnit/SwiftTestingUtilities/ExceptionCatcher.m b/FirebaseCore/Tests/SwiftUnit/SwiftTestingUtilities/ExceptionCatcher.m index 01442bafa0d..a18ff443460 100644 --- a/FirebaseCore/Tests/SwiftUnit/SwiftTestingUtilities/ExceptionCatcher.m +++ b/FirebaseCore/Tests/SwiftUnit/SwiftTestingUtilities/ExceptionCatcher.m @@ -13,7 +13,6 @@ // limitations under the License. #import "FirebaseCore/Tests/SwiftUnit/SwiftTestingUtilities/ExceptionCatcher.h" -#import "FirebaseCore/Sources/Private/FIRErrorCode.h" @implementation ExceptionCatcher @@ -30,6 +29,7 @@ + (BOOL)catchException:(ThrowingBlock)block error:(__autoreleasing NSError **)er [info setValue:exception.userInfo forKey:@"ExceptionUserInfo"]; // Just using error code `FIRErrorCodeConfigFailed` for now + NSInteger FIRErrorCodeConfigFailed = -114; *error = [[NSError alloc] initWithDomain:exception.name code:FIRErrorCodeConfigFailed userInfo:info]; diff --git a/FirebaseCore/Tests/Unit/FIRAppTest.m b/FirebaseCore/Tests/Unit/FIRAppTest.m index 07b4e6cf405..17a0aef3d8d 100644 --- a/FirebaseCore/Tests/Unit/FIRAppTest.m +++ b/FirebaseCore/Tests/Unit/FIRAppTest.m @@ -371,17 +371,6 @@ - (void)testDeleteApp { XCTAssertNil(FIR_COMPONENT(FIRTestProtocolEagerCached, app.container)); } -- (void)testErrorForSubspecConfigurationFailure { - NSError *error = [FIRApp errorForSubspecConfigurationFailureWithDomain:kFirebaseCoreErrorDomain - errorCode:-38 - service:@"Auth" - reason:@"some reason"]; - XCTAssertNotNil(error); - XCTAssert([error.domain isEqualToString:kFirebaseCoreErrorDomain]); - XCTAssert(error.code == -38); - XCTAssert([error.description containsString:@"Configuration failed for"]); -} - - (void)testOptionsLocking { FIROptions *options = [[FIROptions alloc] initWithGoogleAppID:kGoogleAppID GCMSenderID:kGCMSenderID]; diff --git a/FirebaseDynamicLinks/Sources/FIRDynamicLinks.m b/FirebaseDynamicLinks/Sources/FIRDynamicLinks.m index c835b8c4fa2..5d9f0f3a9bd 100644 --- a/FirebaseDynamicLinks/Sources/FIRDynamicLinks.m +++ b/FirebaseDynamicLinks/Sources/FIRDynamicLinks.m @@ -185,11 +185,15 @@ - (void)configureDynamicLinks:(FIRApp *)app { urlScheme:urlScheme userDefaults:nil]; } else { - error = - [FIRApp errorForSubspecConfigurationFailureWithDomain:kFirebaseDurableDeepLinkErrorDomain - errorCode:FIRErrorCodeDurableDeepLinkFailed - service:@"DynamicLinks" - reason:errorDescription]; + NSString *description = + [NSString stringWithFormat:@"Configuration failed for service DynamicLinks."]; + NSDictionary *errorDict = @{ + NSLocalizedDescriptionKey : description, + NSLocalizedFailureReasonErrorKey : errorDescription + }; + error = [NSError errorWithDomain:kFirebaseDurableDeepLinkErrorDomain + code:FIRErrorCodeDurableDeepLinkFailed + userInfo:errorDict]; } if (error) { NSString *message = nil; diff --git a/FirebaseRemoteConfig/Sources/FIRRemoteConfigComponent.m b/FirebaseRemoteConfig/Sources/FIRRemoteConfigComponent.m index b82c13dc59c..6bdcd8b0f4b 100644 --- a/FirebaseRemoteConfig/Sources/FIRRemoteConfigComponent.m +++ b/FirebaseRemoteConfig/Sources/FIRRemoteConfigComponent.m @@ -49,6 +49,7 @@ - (FIRRemoteConfig *)remoteConfigForNamespace:(NSString *)remoteConfigNamespace } if (errorPropertyName) { + NSString *const kFirebaseConfigErrorDomain = @"com.firebase.config"; [NSException raise:kFirebaseConfigErrorDomain format:@"%@",