improve (RCTJSErrorFromCodeMessageAndNSError)

Summary:
First of all,please forgive my poor english. LOL

When I use Promises  as callBack,

 I followed the guide to make a (RCTPromiseRejectBlock),in this RCTPromiseRejectBlock,

from the guide I should add a (NSString)code a (NSString)message and an (NSError) to a  RCTPromiseRejectBlock.

As what did guide said I just make a NSError with

```
 NSError *error=[NSError errorWithDomain:@"native stroage error" code:402 userInfo:@{@"data":key}];

```

As you can see, I want to transfer some data in this callback.But I just found the (userInfo) of NSError didn't composed to a  RCTPromiseRejectBlock.

So I check out the source code of RCTUtil ,I found this

```

// TODO: Can we just replace RCTMakeError with this function instead?
NSDictionary<NSString *, id> *RCTJSErrorFromCodeMessageAndNSError(NSString *code,
                                                                  NSString *message,
                                                                  NSError *__nullable error)
{
  NSString *errorMessage;
Closes https://github.com/facebook/react-native/pull/9519

Differential Revision: D3821334

Pulled By: javache

fbshipit-source-id: 0fa40dd93932af70123b8f8a20a5c7dc5afdd6ac
This commit is contained in:
BaihaoTian 2016-09-06 06:02:24 -07:00 коммит произвёл Facebook Github Bot 2
Родитель 8d013c2326
Коммит d31756bf01
1 изменённых файлов: 2 добавлений и 0 удалений

Просмотреть файл

@ -424,6 +424,8 @@ NSDictionary<NSString *, id> *RCTJSErrorFromCodeMessageAndNSError(NSString *code
errorInfo[@"domain"] = RCTErrorDomain;
}
errorInfo[@"code"] = code ?: RCTErrorUnspecified;
errorInfo[@"userInfo"] = RCTNullIfNil(error.userInfo);
// Allow for explicit overriding of the error message
errorMessage = message ?: errorMessage;