Index: t3lib/class.t3lib_db.php
===================================================================
--- t3lib/class.t3lib_db.php	(revision 7281)
+++ t3lib/class.t3lib_db.php	(working copy)
@@ -384,7 +384,7 @@
 
 	/**
 	 * Truncates a table.
-	 * 
+	 *
 	 * @param	string		Database tablename
 	 * @return	mixed		Result from handler
 	 */
@@ -514,8 +514,10 @@
 				return $query;
 			}
 		} else {
-			die('<strong>TYPO3 Fatal Error:</strong> "Where" clause argument for UPDATE ' .
-				'query was not a string in $this->UPDATEquery() !');
+			throw new InvalidArgumentException(
+				'TYPO3 Fatal Error: "Where" clause argument for UPDATE query was not a string in $this->UPDATEquery() !',
+				1270853880
+			);
 		}
 	}
 
@@ -539,8 +541,10 @@
 			}
 			return $query;
 		} else {
-			die('<strong>TYPO3 Fatal Error:</strong> "Where" clause argument for DELETE ' .
-				'query was not a string in $this->DELETEquery() !');
+			throw new InvalidArgumentException(
+				'TYPO3 Fatal Error: "Where" clause argument for DELETE query was not a string in $this->DELETEquery() !',
+				1270853881
+			);
 		}
 	}
 
@@ -582,7 +586,7 @@
 	/**
 	 * Creates a SELECT SQL-statement to be used as subquery within another query.
 	 * BEWARE: This method should not be overriden within DBAL to prevent quoting from happening.
-	 * 
+	 *
 	 * @param	string		$select_fields: List of fields to select from the table.
 	 * @param	string		$from_table: Table from which to select.
 	 * @param	string		$where_clause: Conditional WHERE statement
@@ -604,7 +608,7 @@
 
 	/**
 	 * Creates a TRUNCATE TABLE SQL-statement
-	 * 
+	 *
 	 * @param	string		See exec_TRUNCATEquery()
 	 * @return	string		Full SQL query for TRUNCATE TABLE
 	 */
@@ -1319,16 +1323,21 @@
 	function connectDB() {
 		if ($this->sql_pconnect(TYPO3_db_host, TYPO3_db_username, TYPO3_db_password)) {
 			if (!TYPO3_db) {
-				die('No database selected');
-				exit;
+				throw new InvalidArgumentException(
+					'TYPO3 Fatal Error: No database selected!',
+					1270853882
+				);
 			} elseif (!$this->sql_select_db(TYPO3_db)) {
-				die('Cannot connect to the current database, "' . TYPO3_db . '"');
-				exit;
+				throw new InvalidArgumentException(
+					'TYPO3 Fatal Error: Cannot connect to the current database, "' . TYPO3_db . '"!',
+					1270853883
+				);
 			}
 		} else {
-			die('The current username, password or host was not accepted when the ' .
-				'connection to the database was attempted to be established!');
-			exit;
+			throw new InvalidArgumentException(
+				'TYPO3 Fatal Error: The current username, password or host was not accepted when the connection to the database was attempted to be established!',
+				1270853884
+			);
 		}
 	}
 
Index: t3lib/class.t3lib_div.php
===================================================================
--- t3lib/class.t3lib_div.php	(revision 7281)
+++ t3lib/class.t3lib_div.php	(working copy)
@@ -1081,8 +1081,18 @@
 	 * @return	string		Returns the list without any duplicates of values, space around values are trimmed
 	 */
 	public static function uniqueList($in_list, $secondParameter=NULL)	{
-		if (is_array($in_list))	die('t3lib_div::uniqueList() does NOT support array arguments anymore! Only string comma lists!');
-		if (isset($secondParameter))	die('t3lib_div::uniqueList() does NOT support more than a single argument value anymore. You have specified more than one.');
+		if (is_array($in_list)) {
+			throw new InvalidArgumentException(
+				'TYPO3 Fatal Error: t3lib_div::uniqueList() does NOT support array arguments anymore! Only string comma lists!',
+				1270853885
+			);
+		}
+		if (isset($secondParameter)) {
+			throw new InvalidArgumentException(
+				'TYPO3 Fatal Error: t3lib_div::uniqueList() does NOT support more than a single argument value anymore. You have specified more than one!',
+				1270853886
+			);
+		}
 
 		return implode(',',array_unique(self::trimExplode(',',$in_list,1)));
 	}
@@ -4467,7 +4477,10 @@
 				include($fileRef);
 				if (!is_array($LOCAL_LANG))	{
 					$fileName = substr($fileRef, strlen(PATH_site));
-					die('\'' . $fileName . '\' is no TYPO3 language file)!');
+					throw new InvalidArgumentException(
+						'TYPO3 Fatal Error: "' . $fileName . '" is no TYPO3 language file!',
+						1270853900
+					);
 				}
 
 					// converting the default language (English)
@@ -4487,7 +4500,12 @@
 					// Cache the content now:
 				$serContent = array('origFile'=>$hashSource, 'LOCAL_LANG'=>array('default'=>$LOCAL_LANG['default'], $langKey=>$LOCAL_LANG[$langKey]));
 				$res = self::writeFileToTypo3tempDir($cacheFileName, serialize($serContent));
-				if ($res)	die('ERROR: '.$res);
+				if ($res) {
+					throw new InvalidArgumentException(
+						'TYPO3 Fatal Error: "' . $res,
+						1270853901
+					);
+				}
 			} else {
 					// Get content from cache:
 				$serContent = unserialize(self::getUrl($cacheFileName));
@@ -4544,7 +4562,10 @@
 				$xmlContent = self::xml2array($xmlString);
 				if (!is_array($xmlContent)) {
 					$fileName = substr($fileRef, strlen(PATH_site));
-					die('The file "' . $fileName . '" is no TYPO3 language file!');
+					throw new InvalidArgumentException(
+						'TYPO3 Fatal Error: The file "' . $fileName . '" is no TYPO3 language file!',
+						1270853902
+					);
 				}
 
 					// Set default LOCAL_LANG array content:
@@ -4583,7 +4604,12 @@
 					// Cache the content now:
 				$serContent = array('origFile'=>$hashSource, 'LOCAL_LANG'=>array('default'=>$LOCAL_LANG['default'], $langKey=>$LOCAL_LANG[$langKey]));
 				$res = self::writeFileToTypo3tempDir($cacheFileName, serialize($serContent));
-				if ($res)	die('ERROR: '.$res);
+				if ($res) {
+					throw new InvalidArgumentException(
+						'TYPO3 Fatal Error: ' . $res,
+						1270853903
+					);
+				}
 			} else {
 					// Get content from cache:
 				$serContent = unserialize(self::getUrl($cacheFileName));
@@ -4611,7 +4637,10 @@
 						$local_xmlContent = self::xml2array($local_xmlString);
 						if (!is_array($local_xmlContent)) {
 							$fileName = substr($localized_file, strlen(PATH_site));
-							die('The file "' . $fileName . '" is no TYPO3 language file!');
+							throw new InvalidArgumentException(
+								'TYPO3 Fatal Error: The file "' . $fileName . '" is no TYPO3 language file!',
+								1270853904
+							);
 						}
 						$LOCAL_LANG[$langKey] = is_array($local_xmlContent['data'][$langKey]) ? $local_xmlContent['data'][$langKey] : array();
 
@@ -4626,7 +4655,10 @@
 						$serContent = array('extlang'=>$langKey, 'origFile'=>$hashSource, 'EXT_DATA'=>$LOCAL_LANG[$langKey]);
 						$res = self::writeFileToTypo3tempDir($cacheFileName, serialize($serContent));
 						if ($res) {
-							die('ERROR: '.$res);
+							throw new InvalidArgumentException(
+								'TYPO3 Fatal Error: ' . $res,
+								1270853905
+							);
 						}
 					} else {
 							// Get content from cache:
Index: t3lib/class.t3lib_extmgm.php
===================================================================
--- t3lib/class.t3lib_extmgm.php	(revision 7281)
+++ t3lib/class.t3lib_extmgm.php	(working copy)
@@ -131,7 +131,12 @@
 	 */
 	public static function isLoaded($key, $exitOnError = 0) {
 		global $TYPO3_LOADED_EXT;
-		if ($exitOnError && !isset($TYPO3_LOADED_EXT[$key]))	die('Fatal Error: Extension "'.$key.'" was not loaded.');
+		if ($exitOnError && !isset($TYPO3_LOADED_EXT[$key])) {
+			throw new InvalidArgumentException(
+				'TYPO3 Fatal Error: Extension "' . $key . '" was not loaded!',
+				1270853910
+			);
+		}
 		return isset($TYPO3_LOADED_EXT[$key]);
 	}
 
@@ -148,8 +153,10 @@
 	public static function extPath($key, $script = '') {
 		global $TYPO3_LOADED_EXT;
 		if (!isset($TYPO3_LOADED_EXT[$key])) {
-			#debug(array(debug_backtrace()));
-			die('TYPO3 Fatal Error: Extension key "'.$key.'" was NOT loaded! (t3lib_extMgm::extPath)');
+			throw new InvalidArgumentException(
+				'TYPO3 Fatal Error: Extension key "'.$key.'" was NOT loaded!',
+				1270853878
+			);
 		}
 		return PATH_site.$TYPO3_LOADED_EXT[$key]['siteRelPath'].$script;
 	}
@@ -166,7 +173,10 @@
 	public static function extRelPath($key) {
 		global $TYPO3_LOADED_EXT;
 		if (!isset($TYPO3_LOADED_EXT[$key])) {
-			die('TYPO3 Fatal Error: Extension key "'.$key.'" was NOT loaded! (t3lib_extMgm::extRelPath)');
+			throw new InvalidArgumentException(
+				'TYPO3 Fatal Error: Extension key "'.$key.'" was NOT loaded!',
+				1270853879
+			);
 		}
 		return $TYPO3_LOADED_EXT[$key]['typo3RelPath'];
 	}
Index: t3lib/class.t3lib_extobjbase.php
===================================================================
--- t3lib/class.t3lib_extobjbase.php	(revision 7281)
+++ t3lib/class.t3lib_extobjbase.php	(working copy)
@@ -203,7 +203,10 @@
 			// Path of this script:
 		$this->thisPath = dirname($conf['path']);
 		if (!@is_dir($this->thisPath))	{
-			die('Error: '.$this->thisPath.' was not a directory as expected...');
+			throw new InvalidArgumentException(
+				'TYPO3 Fatal Error: Extension "' . $this->thisPath . ' was not a directory as expected...',
+				1270853912
+			);
 		}
 
 			// Local lang:
Index: t3lib/class.t3lib_install.php
===================================================================
--- t3lib/class.t3lib_install.php	(revision 7281)
+++ t3lib/class.t3lib_install.php	(working copy)
@@ -208,11 +208,17 @@
 		$writeToLocalconf_dat['tmpfile'] = $writeToLocalconf_dat['file'].$tmpExt;
 
 			// Checking write state of localconf.php:
-		if (!$this->allowUpdateLocalConf)	{
-			die('->allowUpdateLocalConf flag in the install object is not set and therefore "localconf.php" cannot be altered.');
+		if (!$this->allowUpdateLocalConf) {
+			throw new InvalidArgumentException(
+				'TYPO3 Fatal Error: ->allowUpdateLocalConf flag in the install object is not set and therefore "localconf.php" cannot be altered.',
+				1270853915
+			);
 		}
 		if (!@is_writable($writeToLocalconf_dat['file']))	{
-			die($writeToLocalconf_dat['file'].' is not writable!');
+			throw new InvalidArgumentException(
+				'TYPO3 Fatal Error: ' . $writeToLocalconf_dat['file'] . ' is not writable!',
+				1270853916
+			);
 		}
 
 				// Splitting localconf.php file into lines:
@@ -465,7 +471,12 @@
 						}
 
 						$total[$table]['fields'][$fN] = $sqlParser->compileFieldCfg($fInfo);
-						if ($sqlParser->parse_error)	die($sqlParser->parse_error);
+						if ($sqlParser->parse_error) {
+							throw new InvalidArgumentException(
+								'TYPO3 Fatal Error: ' . $sqlParser->parse_error,
+								1270853961
+							);
+						}
 					}
 				}
 			}
Index: t3lib/class.t3lib_tcemain.php
===================================================================
--- t3lib/class.t3lib_tcemain.php	(revision 7281)
+++ t3lib/class.t3lib_tcemain.php	(working copy)
@@ -2712,8 +2712,6 @@
 		}
 
 		$this->accumulateForNotifEmail = array();	// Reset notification array
-
-#		die("REMOVE ME");
 	}
 
 
@@ -5708,7 +5706,12 @@
 			$perms = intval($perms);
 		}
 
-		if (!$perms)	{die('Internal ERROR: no permissions to check for non-admin user.');}
+		if (!$perms) {
+			throw new InvalidArgumentException(
+				'Internal ERROR: no permissions to check for non-admin user',
+				1270853920
+			);
+		}
 
 			// For all tables: Check if record exists:
 		if (is_array($TCA[$table]) && $id>0 && ($this->isRecordInWebMount($table,$id) || $this->admin))	{
@@ -7428,7 +7431,10 @@
 							if (!preg_match('/[^[:alnum:]_]/',$tableName) && substr($tableName,-5)=='cache')	{
 								$GLOBALS['TYPO3_DB']->exec_DELETEquery($tableName,'');
 							} else {
-								die('Fatal Error: Trying to flush table "'.$tableName.'" with "Clear All Cache"');
+								throw new InvalidArgumentException(
+									'TYPO3 Fatal Error: Trying to flush table "' . $tableName . '" with "Clear All Cache"',
+									1270853922
+								);
 							}
 						}
 					}
Index: t3lib/class.t3lib_userauth.php
===================================================================
--- t3lib/class.t3lib_userauth.php	(revision 7281)
+++ t3lib/class.t3lib_userauth.php	(working copy)
@@ -485,9 +485,12 @@
 			if ($this->formfield_status && $loginData['uident'] && $loginData['uname'])	{
 				$httpHost = t3lib_div::getIndpEnv('TYPO3_HOST_ONLY');
 				if (!$this->getMethodEnabled && ($httpHost!=$authInfo['refInfo']['host'] && !$GLOBALS['TYPO3_CONF_VARS']['SYS']['doNotCheckReferer']))	{
-					die('Error: This host address ("'.$httpHost.'") and the referer host ("'.$authInfo['refInfo']['host'].'") mismatches!<br />
+					throw new InvalidArgumentException(
+						'TYPO3 Fatal Error: Error: This host address ("' . $httpHost . '") and the referer host ("' . $authInfo['refInfo']['host'] . '") mismatches!<br />
 						It\'s possible that the environment variable HTTP_REFERER is not passed to the script because of a proxy.<br />
-						The site administrator can disable this check in the "All Configuration" section of the Install Tool (flag: TYPO3_CONF_VARS[SYS][doNotCheckReferer]).');
+						The site administrator can disable this check in the "All Configuration" section of the Install Tool (flag: TYPO3_CONF_VARS[SYS][doNotCheckReferer]).',
+						1270853930
+					);
 				}
 
 					// delete old user session if any
@@ -496,7 +499,10 @@
 
 				// Refuse login for _CLI users (used by commandline scripts)
 			if ((strtoupper(substr($loginData['uname'],0,5))=='_CLI_') && (!defined('TYPO3_cliMode') || !TYPO3_cliMode))	{	// although TYPO3_cliMode should never be set when using active login...
-				die('Error: You have tried to login using a CLI user. Access prohibited!');
+				throw new InvalidArgumentException(
+					'TYPO3 Fatal Error: You have tried to login using a CLI user. Access prohibited!',
+					1270853931
+				);
 			}
 		}
 
@@ -874,12 +880,12 @@
 	 * if the client is flash (e.g. from a flash application inside TYPO3 that does a server request)
 	 * then don't evaluate with the hashLockClause, as the client/browser is included in this hash
 	 * and thus, the flash request would be rejected
-	 * 
+	 *
 	 * @return DB result object or false on error
 	 * @access private
 	 */
 	protected function fetchUserSessionFromDB() {
-		
+
 		if ($GLOBALS['CLIENT']['BROWSER'] == 'flash') {
 			// if on the flash client, the veri code is valid, then the user session is fetched
 			// from the DB without the hashLock clause
@@ -974,7 +980,7 @@
 	public function veriCode() {
 		return substr(md5($this->id . $GLOBALS['TYPO3_CONF_VARS']['SYS']['encryptionKey']), 0, 10);
 	}
-	
+
 	/**
 	 * This returns the where-clause needed to lock a user to a hash integer
 	 *
Index: t3lib/config_default.php
===================================================================
--- t3lib/config_default.php	(revision 7281)
+++ t3lib/config_default.php	(working copy)
@@ -395,7 +395,9 @@
 $typo_db_extTableDef_script = '';	// The filename of an additional script in typo3conf/-folder which is included after tables.php. Code in this script should modify the tables.php-configuration only, and this provides a good way to extend the standard-distributed tables.php file.
 
 	// Include localconf.php. Use this file to configure TYPO3 for your needs and database
-if (!@is_file(PATH_typo3conf.'localconf.php'))	die('localconf.php is not found!');
+if (!@is_file(PATH_typo3conf . 'localconf.php')) {
+	throw new Exception('localconf.php is not found!');
+}
 require(PATH_typo3conf.'localconf.php');
 
 	// Defining the database setup as constants
Index: t3lib/thumbs.php
===================================================================
--- t3lib/thumbs.php	(revision 7281)
+++ t3lib/thumbs.php	(working copy)
@@ -174,7 +174,10 @@
 			$this->size = $size;
 			$this->mtime = $mtime;
 		} else {
-			die('Error: Image does not exist and/or MD5 checksum did not match.');
+			throw new InvalidArgumentException(
+				'TYPO3 Fatal Error: Image does not exist and/or MD5 checksum did not match.',
+				1270853950
+			);
 		}
 	}
 
@@ -277,7 +280,12 @@
 	function errorGif($l1,$l2,$l3)	{
 		global $TYPO3_CONF_VARS;
 
-		if (!$TYPO3_CONF_VARS['GFX']['gdlib'])	die($l1.' '.$l2.' '.$l3);
+		if (!$TYPO3_CONF_VARS['GFX']['gdlib']) {
+			throw new InvalidArgumentException(
+				'TYPO3 Fatal Error: No gdlib. ' . $l1 . ' ' . $l2 . ' ' . $l3,
+				1270853952
+			);
+		}
 
 			// Creates the basis for the error image
 		if ($TYPO3_CONF_VARS['GFX']['gdlib_png'])	{
@@ -329,7 +337,12 @@
 	function fontGif($font)	{
 		global $TYPO3_CONF_VARS;
 
-		if (!$TYPO3_CONF_VARS['GFX']['gdlib'])	die('');
+		if (!$TYPO3_CONF_VARS['GFX']['gdlib']) {
+			throw new InvalidArgumentException(
+				'TYPO3 Fatal Error: No gdlib.',
+				1270853953
+			);
+		}
 
 			// Create image and set background color to white.
 		$im = imageCreate(250,76);
Index: typo3/mod/tools/em/class.em_index.php
===================================================================
--- typo3/mod/tools/em/class.em_index.php	(revision 7281)
+++ typo3/mod/tools/em/class.em_index.php	(working copy)
@@ -2321,7 +2321,11 @@
 					Header('Content-Disposition: attachment; filename='.basename($dlFile));
 					echo t3lib_div::getUrl($dlFile);
 					exit;
-				} else die($GLOBALS['LANG']->getLL('ext_details_error_downloading'));
+				} else {
+					throw new Exception(
+						'TYPO3 Fatal Error: ' . $GLOBALS['LANG']->getLL('ext_details_error_downloading')
+					);
+				}
 
 			} elseif ($this->CMD['editFile'] && !in_array($extKey,$this->requiredExt))	{
 
@@ -2990,7 +2994,11 @@
 				$content = '<table border="0" cellpadding="2" cellspacing="2">'.implode('',$lines).'</table>';
 				return $content;
 			}
-		} else die($GLOBALS['LANG']->getLL('extBackup_unexpected_error'));
+		} else {
+			throw new Exception(
+				'TYPO3 Fatal Error: ' . $GLOBALS['LANG']->getLL('extBackup_unexpected_error')
+			);
+		}
 	}
 
 	/**
@@ -5314,9 +5322,9 @@
 									$finalDir = PATH_site.$crDirStart;
 								}
 							} else {
-								die(sprintf($GLOBALS['LANG']->getLL('checkUploadFolder_error'),
-									PATH_site . $crDir
-									)
+								throw new Exception(
+									'TYPO3 Fatal Error: ' . sprintf($GLOBALS['LANG']->getLL('checkUploadFolder_error'),
+									PATH_site . $crDir)
 								);
 							}
 						}
@@ -5692,7 +5700,9 @@
 				$header.chr(10).chr(10).chr(10).
 				$insertStatements.chr(10).chr(10).chr(10);
 			} else {
-				die($GLOBALS['LANG']->getLL('dumpStaticTables_table_not_found'));
+				throw new Exception(
+					'TYPO3 Fatal Error: ' . $GLOBALS['LANG']->getLL('dumpStaticTables_table_not_found')
+				);
 			}
 		}
 		return $out;
Index: typo3/mod/tools/em/class.em_unzip.php
===================================================================
--- typo3/mod/tools/em/class.em_unzip.php	(revision 7281)
+++ typo3/mod/tools/em/class.em_unzip.php	(working copy)
@@ -123,9 +123,11 @@
 
 		// Check the zlib
 		if (!extension_loaded('zlib')) {
-			die("The extension 'zlib' couldn't be found.\n".
-			"Please make sure your version of PHP was built ".
-			"with 'zlib' support.\n");
+			throw new Exception(
+				'TYPO3 Fatal Error: ' . "The extension 'zlib' couldn't be found.\n".
+				"Please make sure your version of PHP was built ".
+				"with 'zlib' support.\n"
+			);
 		}
 
 		// Set the attributes
