public static function toJson($e, bool $getTrace = true, string $catcher = null): string
    {
        if (!$getTrace) {
            return \json_encode(['msg' => "Error: {$e->getMessage()}"]);
        }

        $map = [
            'code' => $e->getCode() ?: 500,
            'msg'  => sprintf(
                '%s(%d): %s, File: %s(Line %d)',
                \get_class($e),
                $e->getCode(),
                $e->getMessage(),
                $e->getFile(),
                $e->getLine()
            ),
            'data' => $e->getTrace()
        ];

        if ($catcher) {
            $map['catcher'] = $catcher;
        }

        if ($getTrace) {
            $map['trace'] = $e->getTrace();
        }

        return \json_encode($map);
    }