June 2018
Beginner to intermediate
394 pages
9h 2m
English
As a developer, we come across so many cases where errors occur. Storage offers UploadTask and FileDownloadTask, which can listen to the failures through onFailure listeners.
By writing our own custom FailureListener, we can handle the errors in a much better way. For example, consider the following class:
class AppFailureListener implements OnFailureListener { @Override public void onFailure(@NonNull Exception exception) { int errorCode = ((StorageException) exception).getErrorCode(); String errorMessage = exception.getMessage(); }}
This code returns an error message, which is the point of common error scenarios:
|
Code |
Reason |
|
ERROR_UNKNOWN |
When an unknown error occurred |
|
ERROR_OBJECT_NOT_FOUND |
When ... |
Read now
Unlock full access