Page MenuHomePhabricator

correct way for error handling
Closed, DeclinedPublic

Description

When writing I sometimes have time-outs or errors. is there a way to receive the errors with the information? It seems the library is not using a try catch?

try{
$saver->save( $revision);
} catch (Exception $e) {
      return $e;
}

Event Timeline

When you say "I sometimes have time-outs or errors" are you getting exceptions for these?
If so, yes you can catch them and get extra information from them.

Aklapper changed the task status from Open to Stalled.Sep 14 2017, 9:02 PM

@Hannolans: Could you please answer the last comment?

Writing to wikidata returns sometimes errors that stops the system. The following errors occur and it would be great if Addwiki can handle them. One is if there is something with the wikilinks, other are redirects. It would be really convenient if with an redirect it read/write the redirect instead of an error.

  • StatusText: Service unavailable (with message) ResponseText: Mediawiki\Api\UsageException: The external client site "eowiki" did not provide page information for page "Rembrandt Harmenszoon van Rijn". in Mediawiki\Api\MediawikiApi->throwUsageExceptions() (line 273 of MediawikiApi.php).
  • StatusText: Service unavailable (with message) ResponseText: Mediawiki\Api\UsageException: The given entity ID refers to a redirect, which is not supported in this context. in Mediawiki\Api\MediawikiApi->throwUsageExceptions() (line 273 of MediawikiApi.php.
  • StatusText: Service unavailable (with message) ResponseText: Mediawiki\Api\UsageException: The save has failed. in Mediawiki\Api\MediawikiApi->throwUsageExceptions() (line 273 of MediawikiApi.php).
Aklapper changed the task status from Stalled to Open.Sep 17 2017, 1:55 PM

These are all normal Exceptions and can be caught as normal, and handled however your application sees fit.

Can you explain more of what you're doing and maybe the actual try-catch block you're using? (The one above just re-throws the caught Exception, and so does nothing.)