Customising Error Handling

Custom Error Messages

You can completely override the internal error handling by setting an informal shouldDisplayError delegate on your DocumentManager.

If you return false or NO, Pugpig will assume you've displayed an appropriate error and suppress its own error dialog.


@implementation AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { ... KGDocumentManager *dm = [KGDocumentManager sharedManager]; [dm setDownloadDelegate:self]; ... } // implement shouldDisplayError - (BOOL)shouldDisplayError:(NSError *)error title:(NSString*)title message:(NSString*)message { // Display your own error message here return NO; } ...


public class AppDelegate implements ApplicationDelegate {
@Override public void didFinishLaunching() { ... DocumentManager dm = DocumentManager.sharedManager(); // set download delegate: dm.setDownloadDelegate(this); ... } // implement shouldDisplayError boolean shouldDisplayError(Exception error, String title, String message){ //Display your own error message HERE return false; } ...

Intercepting download failures

Similarly, your delegate will receieve a callback if a specific file fails to download. If your delegate returns true or YES, Pugpig will assume you've handled the problem gracefully and will not report a download error. However, please note that it won't magically fix problems - if you ignore errors, some of your content may be missing.


- (BOOL)connection:(KGURLConnection *)connection didFailWithError:(NSError *)error;


boolean connectionDidFailWithError(AssetURLConnection connection, Exception error);
Was this article helpful?
0 out of 0 found this helpful
Have more questions? Submit a request


Powered by Zendesk