Add TextWriter, IOException, per-VM module data and pre-load imports; Add console module with Console class
This commit is contained in:
@@ -1,7 +1,8 @@
|
||||
import 'console';
|
||||
class ExceptionHandler {
|
||||
|
||||
public static void printException(Exception $e) {
|
||||
print('Uncaught ' + get_class($e) + ', code: ' + $e->getCode() + "\nMessage: " + htmlentities($e->getMessage()) + "\n");
|
||||
Console::Print('Uncaught ' + get_class($e) + ', code: ' + $e->getCode() + "\nMessage: " + htmlentities($e->getMessage()) + "\n");
|
||||
}
|
||||
|
||||
public static void handleException(Exception $e) {
|
||||
@@ -21,21 +22,21 @@ class Program {
|
||||
};
|
||||
set_exception_handler($handler);
|
||||
try {
|
||||
print("Called try block 0\n");
|
||||
Console::Print("Called try block 0\n");
|
||||
} finally {
|
||||
print("Called finally block 0\n");
|
||||
Console::Print("Called finally block 0\n");
|
||||
}
|
||||
try {
|
||||
throw new NewException("Catch me once", 1);
|
||||
} catch(Exception $e) {
|
||||
ExceptionHandler::handleException($e);
|
||||
} finally {
|
||||
print("Called finally block 1\n");
|
||||
Console::Print("Called finally block 1\n");
|
||||
}
|
||||
try {
|
||||
throw new NewException("Catch me twice", 2);
|
||||
} finally {
|
||||
print("Called finally block 2\n");
|
||||
Console::Print("Called finally block 2\n");
|
||||
}
|
||||
throw new Exception("Catch me thrice", 3);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user