Global error handler
RealyUniqueName opened this issue · comments
Implemented in e21a2e0
PHP provides an ability to globally handle errors, warnings and notices.
Need to implement access to this function from Haxe side.
http://php.net/manual/en/function.set-error-handler.php
Well, the error_handler has a pretty complicated signature and I'm not sure what this errcontext really is and also it can return a string or an array but basically it would be something like this:
@:phpGlobal
extern ErrorHandling {
static function set_error_handler(handler:Int->String->?String->?Int->?NativeArray->Bool, types:Int):String;
}
The problem is that you can't pass in a function directly here, I think only a closure would work. Maybe a Callable<T>
abstract over Function would be a good idea, that converts static and instance functions to arrays? Do you handle function passing already in the generator?
I don't see any problem here.
set_errror_handler
can accept any closure. And closures should be generated correctly (not yet, but it's in the roadmap).
Yeah, but you can't pass obj->func
or Class::func
directly, can you?
I think those will be wrapped in anonymous functions :
var q = MyClass.method;
$q = function () {return MyClass::method()};
I had this idea as well, but there was a problem, but I don't remember (of course).
What about obj->func
?
$q = function () use ($obj) { return $obj->func(); }
Implemented in e21a2e0