Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed issue #936 #937

Merged
merged 5 commits into from
Jan 28, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 24 additions & 9 deletions packages/Webkul/Admin/src/Exceptions/Handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,27 @@

class Handler extends AppExceptionHandler
{
protected $jsonErrorMessages = [
404 => 'Resource not found',
403 => '403 forbidden Error',
401 => 'Unauthenticated',
500 => '500 Internal Server Error',
];
/**
* Json error messages.
*
* @var array
*/
protected $jsonErrorMessages = [];

/**
* Create handler instance.
*
* @return void
*/
public function __construct()
devansh-webkul marked this conversation as resolved.
Show resolved Hide resolved
{
$this->jsonErrorMessages = [
devansh-webkul marked this conversation as resolved.
Show resolved Hide resolved
'404' => trans('admin::app.common.resource-not-found'),
'403' => trans('admin::app.common.forbidden-error'),
'401' => trans('admin::app.common.unauthenticated'),
'500' => trans('admin::app.common.internal-server-error')
];
}
devansh-webkul marked this conversation as resolved.
Show resolved Hide resolved

/**
* Render an exception into an HTTP response.
Expand Down Expand Up @@ -87,11 +102,11 @@ private function response($path, $statusCode)
if (request()->expectsJson()) {
return response()->json([
'message' => isset($this->jsonErrorMessages[$statusCode])
? $this->jsonErrorMessages[$statusCode]
: 'Something went wrong, please try again later.'
? $this->jsonErrorMessages[$statusCode]
: trans('admin::app.common.something-went-wrong')
], $statusCode);
}

return response()->view("{$path}::errors.{$statusCode}", [], $statusCode);
}
}
}
7 changes: 6 additions & 1 deletion packages/Webkul/Admin/src/Resources/lang/ar/app.php
Original file line number Diff line number Diff line change
Expand Up @@ -824,7 +824,12 @@
'select-call' => 'مكالمة',
'select-meeting' => 'لقاء',
'select-lunch' => 'غداء',
'duplicate-value' => 'لا يمكن أن تكون القيمة مكررة'
'duplicate-value' => 'لا يمكن أن تكون القيمة مكررة',
'unauthenticated' => 'غير مصدق',
'resource-not-found' => 'الموارد غير موجود',
'forbidden-error' => 'ممنوع الخطأ',
'internal-server-error' => 'خطأ في الخادم الداخلي',
'something-went-wrong' => 'هناك شئ خاطئ، يرجى المحاولة فى وقت لاحق.'
],

'user' => [
Expand Down
7 changes: 6 additions & 1 deletion packages/Webkul/Admin/src/Resources/lang/en/app.php
Original file line number Diff line number Diff line change
Expand Up @@ -828,7 +828,12 @@
'select-call' => 'Call',
'select-meeting' => 'Meeting',
'select-lunch' => 'Lunch',
'duplicate-value' => 'The value cannot be duplicate'
'duplicate-value' => 'The value cannot be duplicate',
'unauthenticated' => 'Unauthenticated',
'resource-not-found' => 'Resource not found',
'forbidden-error' => '403 forbidden Error',
'internal-server-error' => '500 Internal Server Error',
'something-went-wrong' => 'Something went wrong, please try again later.'
],

'user' => [
Expand Down
7 changes: 6 additions & 1 deletion packages/Webkul/Admin/src/Resources/lang/tr/app.php
Original file line number Diff line number Diff line change
Expand Up @@ -819,7 +819,12 @@
'select-call' => 'Arama Yap',
'select-meeting' => 'Toplantı',
'select-lunch' => 'Öğle Yemeği',
'duplicate-value' => 'Değer yinelenemez'
'duplicate-value' => 'Değer yinelenemez',
'unauthenticated' => 'Kimliği doğrulanmamış',
'resource-not-found' => 'Kaynak bulunamadı',
'forbidden-error' => '403 yasak hatası',
'internal-server-error' => '500 Dahili Sunucu Hatası',
'something-went-wrong' => 'Bir şeyler yanlış oldu. Lütfen sonra tekrar deneyiniz.'
],

'user' => [
Expand Down