Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8852437
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T13:24:03+00:00 2026-06-14T13:24:03+00:00

I have a class I want to redirect user to Error page if theres

  • 0

I have a class I want to redirect user to Error page if theres been an: uncaught exception , a caught exception or a custom exception. I also want to flick off an error email. (so that I’m notified).

I can’t access the current View Controller within this class (in the case of an uncaught exception). Because its triggered with the delegate listener onUncaughtException(NSException* exception).

How can I access the current view controller, or failing that, modally redirect user to an Error view controller?

#import "ErrorHelper.h"
#import "ErrorViewController.h"
#import "Global.h"
#import "AppDelegate.h"

@implementation ErrorHelper


+(void) handleUncaughtError:(NSException*) exception
{
    NSLog(@"Uncaught exception occurred!");
    
    [self sendErrorEmailIfAppropriate:exception :nil];
    [self redirectToErrorPage];
}

+(void) handleCaughtError:(NSException*) exception
{
    NSLog(@"Error caught!!");
    
    [self sendErrorEmailIfAppropriate:exception :nil];
    [self redirectToErrorPage];
}

+(void) handleCaughtCustomError:(NSString*) ref :(NSString*) details
{
    NSLog(@"Custom error caught!!");
    //can do conditional branching on @ref, to do appropriate action.
    
    [self sendErrorEmailIfAppropriate:nil :details];
    [self redirectToErrorPage];
    
    
}

+(void) sendErrorEmailIfAppropriate:(NSException*) exception :(NSString*)details
{
    if([[Global get] isInTestMode] || [[Global get] isInLiveMode]) {
        bool isCustomException = details != nil;
        
    }
}

+(void) redirectToErrorPage
{
    /*Try redirect user to error page
    E.G:
     -There's been an error, our App Dev team will try and resolve the issue for you
     -Regards -Dev team
     
    */
    AppDelegate *appDelegate = [[UIApplication sharedApplication] delegate];
    
}

@end

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T13:24:04+00:00Added an answer on June 14, 2026 at 1:24 pm

    I tried this from: exception_handler Its working! Just write your email sending code instead of the alert view.

    - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
    {        
        [window makeKeyAndVisible];
    
        NSSetUncaughtExceptionHandler(&exceptionHandler);
    
        return YES;
    }
    
    BOOL exceptionAlertDismissed = FALSE;
    void exceptionHandler(NSException *exception)
    {
        UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"App Committed Suicide"
            message:@"Oh dear, that wasn't supposed to happen. You will have to restart the application... sorry!"
            delegate:[[UIApplication sharedApplication] delegate] cancelButtonTitle:nil otherButtonTitles:@"That's ok!", @"Erm, bye...", nil];
        [alert show];
        [alert release];
    
        while (exceptionAlertDismissed == FALSE)
        {
            [[NSRunLoop currentRunLoop] runUntilDate:[NSDate dateWithTimeIntervalSinceNow:0.1]];
        }
    }
    
    - (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
    {
        exceptionAlertDismissed = TRUE;
    }
    

    In interface,

    @interface ...appDelegate : NSObject <UIApplicationDelegate, UIAlertViewDelegate>
    ...
    void exceptionHandler(NSException *exception);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want my error page of my seam application to redirect to the home
OK so I have a User which has_one Template and I want a page
I have class and I want to initalize column that stores pictuer with type
I have a class that I want to contain multiple objects of something I
I have a class and I want to have some bit masks with values
I have a class that I want to include in a GWT module. Unfortunately,
I have a class which I want to add a property with using formula
I have a C++ class I want to inspect. So, I would like to
I have a python class I want to instantiate and the __init__ definition has
I have this class which I want to pass around Windows as LPARAM parameter.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.