ultimatepos/Modules/IndustrialEngineering/Support/OperationErrorMessages.php

54 lines
1.7 KiB
PHP

<?php
namespace Modules\IndustrialEngineering\Support;
use Illuminate\Database\QueryException;
use Throwable;
class OperationErrorMessages
{
public static function for(Throwable $e): string
{
$msg = $e->getMessage();
if (str_contains($msg, 'purchase_line_tax_id')) {
return __('industrialengineering::lang.mrp_po_line_error');
}
if (str_contains($msg, 'ie_mrp_runs') && str_contains($msg, 'created_by')) {
return __('industrialengineering::lang.mrp_created_by_error');
}
if (str_contains($msg, 'maintenance_asset_documents')) {
return __('industrialengineering::lang.cmms_documents_table_missing');
}
if (str_contains($msg, 'maintenance_inspection_visits')
|| str_contains($msg, 'maintenance_service_records')
|| str_contains($msg, 'maintenance_part_replacements')
|| str_contains($msg, 'maintenance_history_entries')) {
return __('industrialengineering::lang.cmms_view_error');
}
if (str_contains($msg, '::parts()')) {
return __('industrialengineering::lang.cmms_view_error');
}
if ($e instanceof QueryException) {
if (str_contains($msg, 'Integrity constraint violation')) {
return __('industrialengineering::lang.mrp_database_error');
}
if (str_contains($msg, 'Base table or view not found')) {
return __('industrialengineering::lang.mrp_database_error');
}
}
if (str_starts_with($msg, 'SQLSTATE')) {
return __('industrialengineering::lang.mrp_database_error');
}
return $msg;
}
}