Skip to content

Commit

Permalink
[0.1.1] Exceptions processing.
Browse files Browse the repository at this point in the history
{2023:10:1:5}
  • Loading branch information
TechnomageLiloi committed Mar 6, 2023
1 parent 159401f commit a7b39fa
Showing 1 changed file with 26 additions and 7 deletions.
33 changes: 26 additions & 7 deletions Backside/Application/Conceptual.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,22 +19,40 @@ protected function get(): string
return '';
}

/**
* Handling exception.
*
* @param \Exception $exception
* @return string
* @throws \Exception
*/
protected function exceptionHandling(\Exception $exception): string
{
throw $exception;
}

/**
* Compiles page.
*
* @return string Full output page.
* @throws \Exception
*/
public function compile(): string
{
if(isset($_POST['method']))
try
{
// API Request
return json_encode([
'response' => $this->api($_POST['method'], $_POST['parameters'])
]);
}
if(isset($_POST['method']))
{
// API Request
return json_encode(['response' => $this->api($_POST['method'], $_POST['parameters'])]);
}

return $this->get();
return $this->get();
}
catch (\Exception $exception)
{
$this->exceptionHandling($exception);
}
}

/**
Expand All @@ -43,6 +61,7 @@ public function compile(): string
* @param string $name API method name.
* @param array $parameters API parameters.
* @return array API
* @throws \Exception
*/
public function api(string $name, array $parameters): array
{
Expand Down

0 comments on commit a7b39fa

Please sign in to comment.