<?php

namespace MODELORA\Viewer;

if (! defined('ABSPATH')) {
    exit;
}

class ErrorHandler
{
    public function register(): void
    {
        add_filter('modelora_user_friendly_error', [$this, 'humanize'], 10, 2);
    }

    public function humanize(string $message, string $type): string
    {
        $defaults = [
            'missing_texture' => __('Some textures are missing. The model can still load, but quality may be reduced.', 'modelora-3d-product-viewer'),
            'broken_model' => __('This 3D model seems broken. Try re-exporting it as GLB.', 'modelora-3d-product-viewer'),
            'wrong_format' => __('This file format is not supported yet. Try GLB for best results.', 'modelora-3d-product-viewer'),
            'oversized' => __('Your file is too large. Click here to optimize.', 'modelora-3d-product-viewer'),
        ];

        return $defaults[$type] ?? $message;
    }
}

