Unity Firebase存储错误未返回错误

时间:2017-04-11 05:24:04

标签: firebase unity3d error-handling firebase-storage

使用Unity从Firebase存储加载文件时:

如果文件不存在,则“ErrorRetryLimitExceeded”是唯一返回的错误,需要几分钟。为什么没有返回“ErrorObjectNotFound”或其他错误?

这是统一代码:

public void Load (string folderName, Action<byte[]> loadResults = null)
{

    StorageFileName (folderName);
    ServicePointToggle (true);
    const long maxAllowedSize = 4 * 1024 * 1024;

    imaginary_ref.GetBytesAsync (maxAllowedSize).ContinueWith (task => {
        if (task.IsFaulted || task.IsCanceled) {
            Debug.Log (FirebaseStorageException (task.Exception));

        } else {
            Debug.Log("success");
        }
    });
}

public string FirebaseStorageException (Exception taskException)
{

    AggregateException ex = taskException as AggregateException;
    if (ex != null) {
        StorageException inner = ex.InnerExceptions [0] as StorageException;

        if (inner != null) {
            switch (inner.ErrorCode) {
            case StorageException.ErrorBucketNotFound:
                errorText = "Bucket Not Found";
                break; 
            case StorageException.ErrorCanceled:
                errorText = "Canceled";
                break; 
            case StorageException.ErrorInvalidChecksum:
                errorText = "Invalid Checksum";
                break; 
            case StorageException.ErrorNotAuthenticated:
                errorText = "Not Authenticated";
                break; 
            case StorageException.ErrorNotAuthorized:
                errorText = "Not Authorized";
                break; 
            case StorageException.ErrorObjectNotFound:
                errorText = "Object Not Found";
                break; 
            case StorageException.ErrorProjectNotFound:
                errorText = "Project Not Found";
                break; 
            case StorageException.ErrorQuotaExceeded:
                errorText = "Quota Exceeded";
                break; 
            case StorageException.ErrorRetryLimitExceeded:
                errorText = "Retry Exceeded";
                break; 
            case StorageException.ErrorUnknown:
                errorText = "Error Unknown";
                break; 
            }

        }

    }
    return errorText;
}

0 个答案:

没有答案