Skip to content

Commit

Permalink
Show debug info when TikTok gives error
Browse files Browse the repository at this point in the history
  • Loading branch information
pablouser1 committed Oct 6, 2023
1 parent 3ba64be commit a3b4143
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 10 deletions.
2 changes: 1 addition & 1 deletion app/Helpers/ErrorHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
class ErrorHandler {
public static function showMeta(Meta $meta) {
http_response_code($meta->httpCode);
Wrappers::latte('error', new ErrorTemplate($meta->httpCode, $meta->proxitokMsg, $meta->proxitokCode));
Wrappers::latte('error', new ErrorTemplate($meta->httpCode, $meta->proxitokMsg, $meta->proxitokCode, $meta->response));
}

public static function showText(int $code, string $msg) {
Expand Down
6 changes: 5 additions & 1 deletion app/Models/ErrorTemplate.php
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
<?php
namespace App\Models;
use TikScraper\Models\Response;

class ErrorTemplate extends BaseTemplate {
public int $http_code = 502;
public ?int $tiktok_code = -1;
public string $msg = '';

public ?Response $response = null;

function __construct(int $http_code, string $msg, ?int $tiktok_code = null) {

function __construct(int $http_code, string $msg, ?int $tiktok_code = null, ?Response $response) {
parent::__construct('Error');
$this->http_code = $http_code;
$this->msg = $msg;
$this->tiktok_code = $tiktok_code;
$this->response = $response;
}
}
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "pablouser1/proxitok",
"description": "An alternative frontend for TikTok",
"version": "2.4.9.3",
"version": "2.4.9.4",
"license": "AGPL-3.0-or-later",
"type": "project",
"authors": [
Expand Down
14 changes: 7 additions & 7 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions templates/views/error.latte
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,11 @@
{else}
<p>{$msg}</p>
{/if}
{if isset($response)}
<details>
<summary>Show debug info</summary>
<pre style="max-height: 60vh;">{json_encode($response, JSON_PRETTY_PRINT)}</pre>
</details>
{/if}
</div>
{/block}

0 comments on commit a3b4143

Please sign in to comment.