From b6da1a23014bffecbf12cb18df121f73fbeb3c1e Mon Sep 17 00:00:00 2001 From: Amory Meltzer Date: Thu, 1 Dec 2022 19:51:48 -0500 Subject: [PATCH] Provide self to _error Should allow custom `on_error` subroutines to not rely upon using a global object --- lib/MediaWiki/API.pm | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/MediaWiki/API.pm b/lib/MediaWiki/API.pm index 79d3041..b4f3cf8 100644 --- a/lib/MediaWiki/API.pm +++ b/lib/MediaWiki/API.pm @@ -132,6 +132,7 @@ An example for the on_error configuration could be something like: Errors are stored in $mw->{error}->{code} with more information in $mw->{error}->{details}. $mw->{error}->{stacktrace} includes the details and a stacktrace to locate where any problems originated from (in some code which uses this module for example). +The MediaWiki::API object itself is provided to the function. The error codes are as follows @@ -900,7 +901,7 @@ sub _error { $self->{error}->{details} = $desc; $self->{error}->{stacktrace} = Carp::longmess($desc); - $self->{config}->{on_error}->() if (defined $self->{config}->{on_error}); + $self->{config}->{on_error}->($self) if (defined $self->{config}->{on_error}); return undef; }