Question: I'm trying to log crashes in my iPhone app by catching all unhandled exceptions and writing the details to the NSUserDefaults. I set it up by adding this to 

```
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {    

NSSetUncaughtExceptionHandler(&uncaughtExceptionHandler);
}

```

and defined the function to handle it like this:

```
void uncaughtExceptionHandler(NSException *exception) {

NSMutableString *errorString = [NSMutableString new];
[errorString appendFormat:@"Exception Name : %@\n", exception.name];
[errorString appendFormat:@"Exception Reason : %@\n", exception.reason];
[errorString appendString:@"User Info : \n"];

for (NSString *key in [[exception userInfo] allKeys]) {
    [errorString appendFormat:@"Key : %@ Value : %@\n", key, [[exception userInfo] valueForKey: key]];
}

[errorString appendFormat:@"Call Stack : %@\n", [exception callStackSymbols]];

[[NSUserDefaults standardUserDefaults] setObject:errorString forKey:@"ErrorLog"];

NSLog(@"Exception : %@", errorString);

```

}

Everything works fine as far as the function being called when there's a crash and the NSLogs print out all the exception details, but nothing ever gets added to the NSUserDefaults, and I have no idea why.

Does anyone have any idea why this wouldn't set an object into the NSUserDefaults?

Thank you for any help...

Answer: 
You need to create a flag variable that you will pass to your view and set it `true` if you want the modal to auto open and set it `false` if you don't want to open it:

The problem with this is that `->with()` doesn't work with `Redirect::back()` so we need a workaround: lets pass our flag variable as an input. For this you have to get all the old input and add the new flag variable to them. Make sure that the key (your flag variable name) doesn't already exist. You can check this with a `var_dump(Input::all())`.

```
$input = Input::all();//Get all the old input.
$input['autoOpenModal'] = 'true';//Add the auto open indicator flag as an input.
return Redirect::back()
    ->withErrors($this->messageBag)
    ->withInput($input);//Passing the old input and the flag.

```

Now in your view you have to print this "old" input into your JavaScript condition. If it exists it will print its value: `true`, otherwise it will print the second argument: `false`.

```
<script>
$(document).ready(function () {
    if ({{ Input::old('autoOpenModal', 'false') }}) {
        //JavaScript code that open up your modal.
    }
});
</script>

```
You can `return false;` when you return the validations results.