Skip to content

Commit

Permalink
New error message for missing callable class.
Browse files Browse the repository at this point in the history
  • Loading branch information
feuzeu committed Jan 25, 2025
1 parent 693652b commit cfa548c
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 8 deletions.
4 changes: 2 additions & 2 deletions src/Plugin/Request/CallableClass/CallableClassPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -238,19 +238,19 @@ public function processRequest()
$sClassName = $this->xTarget->getClassName();
$sMethodName = $this->xTarget->getMethodName();
// Will be used to print a translated error message.
$sError = 'errors.objects.invalid';
$aErrorParams = ['class' => $sClassName, 'method' => $sMethodName];

if(!$this->xValidator->validateClass($sClassName) ||
!$this->xValidator->validateMethod($sMethodName))
{
// Unable to find the requested object or method
$this->throwException('', $sError, $aErrorParams);
$this->throwException('', 'errors.objects.invalid', $aErrorParams);
}

// Call the requested method
try
{
$sError = 'errors.objects.find';
/** @var CallableObject */
$xCallableObject = $this->getCallable($sClassName);

Expand Down
5 changes: 3 additions & 2 deletions translations/en/errors.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,10 @@
'invalid-declaration' => "Invalid function declaration.",
],
'objects' => [
'call' => "An error occured during the call of method :method in of class :class.",
'invalid' => "Invalid object request received; no object :class or method :method found.",
'invalid' => "Invalid object request received: :class or method :method found.",
'missing' => "An error occured during the call; no object :class or method :method found.",
'excluded' => "Trying to call the excluded method :method of class :class.",
'call' => "An error occured during the call of method :method in of class :class.",
'instance' => "To register a callable object, please provide an instance of the desired class.",
'invalid-declaration' => "Invalid object declaration.",
],
Expand Down
5 changes: 3 additions & 2 deletions translations/es/errors.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,10 @@
'invalid-declaration' => "Declaración de funcion invalida.",
],
'objects' => [
'call' => "An error occured during the call of method :method in of class :class",
'invalid' => "Solicitud de objeto invalida recibida; Sin objeto :class o metodo :method encontrado.",
'invalid' => "Solicitud de objeto invalida recibida; objeto :class o metodo :method.",
'missing' => "An error occured during the call; Sin objeto :class o metodo :method encontrado.",
'excluded' => "Trying to call the excluded method :method of class :class.",
'call' => "An error occured during the call of method :method in of class :class",
'instance' => "Para registrar un objeto, por favor de proveer una instancia de la clase deseada.",
'invalid-declaration' => "Declaración de objeto invalida.",
],
Expand Down
5 changes: 3 additions & 2 deletions translations/fr/errors.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,10 @@
'invalid-declaration' => "La déclaration de fonction est invalide.",
],
'objects' => [
'invalid' => "La requête indique un objet invalide : classe :class ou méthode :method.",
'missing' => "Une erreur s'est produite à l'appel; il n'existe pas de classe :class ou de méthode :method.",
'excluded' => "Impossible d'appeler la méthode :method de la classe :class, car elle est exclue.",
'call' => "Une erreur s'est produite à l'appel de la méthode :method de la classe :class.",
'invalid' => "La requête indique un objet invalide; il n'existe pas de classe :class ou de méthode :method.",
'excluded' => "La requête a essayé d'appeler la méthode :method de la classe :class, qui est exclue.",
'instance' => "Pour enregistrer un objet, vous devez fournir une instance de la classe correspondante.",
'invalid-declaration' => "La déclaration d'objet est invalide.",
],
Expand Down

0 comments on commit cfa548c

Please sign in to comment.