From 7210c8944b9ad5599c9befa7f9f9237061b696ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=BAlvio=20Abrah=C3=A3o=20de=20Paula?= Date: Mon, 21 Aug 2023 08:15:11 -0700 Subject: [PATCH] Implicit conversion from nullable pointer 'NSString * _Nullable' to non-nullable pointer type 'NSString * _Nonnull' error + Add missing import. Summary: This diff fixes this compilation error that appear in the next diff (in case I don't fix it before). ``` Action failed: fbsource//xplat/sonar/iOS/Plugins/FlipperKitDatabasesPlugin:FlipperKitDatabasesPlugin (cxx_compile FlipperKitDatabasesPlugin/DatabasesManager.m (pic)) Local command returned non-zero exit code 1 Reproduce locally: `env -- "BUCK_SCRATCH_PATH=buck-out/v2/tmp/fbsource/4f538045b2fada5e/xplat/sonar/iOS/Plugins/FlipperK ...... erKitDatabasesPlugin__/__dep_files_intermediaries__/FlipperKitDatabasesPlugin/DatabasesManager.m.pic (run `buck2 log what-failed` to get the full command)` stdout: stderr: xplat/sonar/iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/DatabasesManager.m:121:57: error: implicit conversion from nullable pointer 'NSString * _Nullable' to non-nullable pointer type 'NSString * _Nonnull' [-Werror,-Wnullable-to-nonnull-conversion] stringByAppendingString:exception.reason]]; ^ xplat/sonar/iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/DatabasesManager.m:157:57: error: implicit conversion from nullable pointer 'NSString * _Nullable' to non-nullable pointer type 'NSString * _Nonnull' [-Werror,-Wnullable-to-nonnull-conversion] stringByAppendingString:exception.reason]]; ^ xplat/sonar/iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/DatabasesManager.m:191:57: error: implicit conversion from nullable pointer 'NSString * _Nullable' to non-nullable pointer type 'NSString * _Nonnull' [-Werror,-Wnullable-to-nonnull-conversion] stringByAppendingString:exception.reason]]; ^ 3 errors generated. ``` Differential Revision: D48438432 fbshipit-source-id: acba91ec8e4fdab2c09a1e98387c203aa0d49489 --- .../FlipperKitDatabasesPlugin/DatabaseDescriptor.h | 2 ++ .../FlipperKitDatabasesPlugin/DatabasesManager.m | 12 ++++++++---- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/DatabaseDescriptor.h b/iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/DatabaseDescriptor.h index e6509a682..3132fdce0 100644 --- a/iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/DatabaseDescriptor.h +++ b/iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/DatabaseDescriptor.h @@ -5,6 +5,8 @@ * LICENSE file in the root directory of this source tree. */ +#import + @protocol DatabaseDescriptor - (NSString*)name; @end diff --git a/iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/DatabasesManager.m b/iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/DatabasesManager.m index 428ab34f4..40b2908f2 100644 --- a/iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/DatabasesManager.m +++ b/iOS/Plugins/FlipperKitDatabasesPlugin/FlipperKitDatabasesPlugin/DatabasesManager.m @@ -115,10 +115,11 @@ databaseGetTableDataResponseToDictionary:tableDataResponse]; [responder success:response]; } @catch (NSException* exception) { + NSString* reason = exception.reason ?: @"Unknown error"; NSDictionary* errorResponse = [ObjectMapper errorWithCode:DatabasesErrorCodesSqlExecutionException message:[kDatabasesErrorCodesSqlExecutionExceptionMessage - stringByAppendingString:exception.reason]]; + stringByAppendingString:reason]]; [responder error:errorResponse]; } }]; @@ -151,10 +152,11 @@ databaseGetTableStructureResponseToDictionary:tableStructure]; [responder success:response]; } @catch (NSException* exception) { + NSString* reason = exception.reason ?: @"Unknown error"; NSDictionary* errorResponse = [ObjectMapper errorWithCode:DatabasesErrorCodesSqlExecutionException message:[kDatabasesErrorCodesSqlExecutionExceptionMessage - stringByAppendingString:exception.reason]]; + stringByAppendingString:reason]]; [responder error:errorResponse]; } }]; @@ -185,10 +187,11 @@ [ObjectMapper databaseGetTableInfoResponseToDictionary:tableInfo]; [responder success:response]; } @catch (NSException* exception) { + NSString* reason = exception.reason ?: @"Unknown error"; NSDictionary* errorResponse = [ObjectMapper errorWithCode:DatabasesErrorCodesSqlExecutionException message:[kDatabasesErrorCodesSqlExecutionExceptionMessage - stringByAppendingString:exception.reason]]; + stringByAppendingString:reason]]; [responder error:errorResponse]; } }]; @@ -215,10 +218,11 @@ [ObjectMapper databaseExecuteSqlResponseToDictionary:sqlResponse]; [responder success:response]; } @catch (NSException* exception) { + NSString* reason = exception.reason ?: @"Unknown error"; NSDictionary* errorResponse = [ObjectMapper errorWithCode:DatabasesErrorCodesSqlExecutionException message:[kDatabasesErrorCodesSqlExecutionExceptionMessage - stringByAppendingString:exception.reason]]; + stringByAppendingString:reason]]; [responder error:errorResponse]; } }];