{"id":1080,"date":"2024-03-03T21:39:21","date_gmt":"2024-03-03T12:39:21","guid":{"rendered":"https:\/\/shinke1987.net\/?p=1080"},"modified":"2024-03-03T21:47:34","modified_gmt":"2024-03-03T12:47:34","slug":"laravel%e3%81%a7%e3%82%aa%e3%83%aa%e3%82%b8%e3%83%8a%e3%83%ab%e4%be%8b%e5%a4%96%e3%82%af%e3%83%a9%e3%82%b9%e3%82%92%e5%88%a9%e7%94%a8%e3%81%99%e3%82%8b","status":"publish","type":"post","link":"https:\/\/shinke1987.net\/?p=1080","title":{"rendered":"Laravel\u3067\u30aa\u30ea\u30b8\u30ca\u30eb\u4f8b\u5916\u30af\u30e9\u30b9\u3092\u5229\u7528\u3059\u308b"},"content":{"rendered":"\n<h2 id=\"toc0\" class=\"wp-block-heading\">\u4f8b\u5916\u30af\u30e9\u30b9\u3068\u30d3\u30e5\u30fc\u3092\u4f5c\u6210<\/h2>\n\n\n\n<p>\u4f8b\u5916\u30af\u30e9\u30b9\u3092\u6b21\u306e\u30b3\u30de\u30f3\u30c9\u3067\u4f5c\u6210\u3002<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: bash; title: ; notranslate\" title=\"\">\n# php artisan make:exception \u4f8b\u5916\u30af\u30e9\u30b9\u540d\n<\/pre><\/div>\n\n\n<p>\u4f8b\u5916\u6642\u306b\u8868\u793a\u3059\u308b\u30d3\u30e5\u30fc\u3092\u4f5c\u6210\u3002<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: php; title: ; notranslate\" title=\"\">\n# php artisan make:view exceptions\/exception\n<\/pre><\/div>\n\n\n<p>resources\/views\/exceptions\/exception.blade.php \u30d5\u30a1\u30a4\u30eb\u304c\u4f5c\u6210\u3055\u308c\u308b\u3002<\/p>\n\n\n\n<h2 id=\"toc1\" class=\"wp-block-heading\">\u4f8b\u5916\u30af\u30e9\u30b9\u306b\u3064\u3044\u3066<\/h2>\n\n\n\n<p>\u4f8b\u5916\u30af\u30e9\u30b9\u306ereport\u30e1\u30bd\u30c3\u30c9\u3068render\u30e1\u30bd\u30c3\u30c9<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>report\u30e1\u30bd\u30c3\u30c9<br>\u4f8b\u5916\u3092\u30ed\u30b0\u306b\u8a18\u9332\u3059\u308b\u3002<\/li>\n\n\n\n<li>render\u30e1\u30bd\u30c3\u30c9<br>\u30ec\u30b9\u30dd\u30f3\u30b9\u3092\u751f\u6210\u3059\u308b\u3002<\/li>\n<\/ul>\n\n\n\n<h2 id=\"toc2\" class=\"wp-block-heading\">\u4f5c\u6210\u3057\u305f\u4f8b\u5916\u30af\u30e9\u30b9<\/h2>\n\n\n\n<p>\u4f5c\u6210\u3057\u305f\u4f8b\u5916\u30af\u30e9\u30b9\uff08Exception\u30af\u30e9\u30b9\uff09\u3092\u7de8\u96c6\u3002<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: php; title: ; notranslate\" title=\"\">\n&lt;?php\n\nnamespace App\\Exceptions;\n\nuse Exception as BaseException;\nuse Illuminate\\Http\\Request;\nuse Illuminate\\Support\\Facades\\Log;\nuse Illuminate\\View\\View;\nuse Throwable;\n\nclass Exception extends BaseException\n{\n\n    public function __construct(string $message = &quot;&quot;, int $code = 0, ?Throwable $previous = null)\n    {\n        parent::__construct($message, $code, $previous);\n    }\n\n    public function report(): void\n    {\n        \/\/ \u6307\u5b9a\u3057\u305f\u5185\u5bb9\u3068\u30ec\u30d9\u30eb\u3067\u30ed\u30b0\u51fa\u529b\n        Log::error($this-&gt;getMessage());\n    }\n\n    public function render(Request $request): View\n    {\n        \/\/ \u6307\u5b9a\u3057\u305f\u30d3\u30e5\u30fc\u3092\u8868\u793a\u3002\n        return view(&#039;exceptions.exception&#039;);\n    }\n}\n<\/pre><\/div>\n\n\n<h2 id=\"toc3\" class=\"wp-block-heading\">\u52d5\u4f5c\u78ba\u8a8d<\/h2>\n\n\n\n<p>\u30b3\u30f3\u30c8\u30ed\u30fc\u30e9\u7b49\u3067\u6b21\u306e\u30b3\u30fc\u30c9\u3092\u5b9f\u884c\u3055\u305b\u308b\u3053\u3068\u3067\u78ba\u8a8d\u3067\u304d\u308b\u3002<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: php; title: ; notranslate\" title=\"\">\nthrow new Exception(&#039;test&#039;);\n<\/pre><\/div>\n\n\n<p>\u3053\u308c\u3067\u4f8b\u5916\u30af\u30e9\u30b9\u306ereport\u30e1\u30bd\u30c3\u30c9\u306b\u3066\u30ed\u30b0\u304c\u51fa\u529b\u3055\u308c\u3001<br>\u4f8b\u5916\u30af\u30e9\u30b9\u306erender\u30e1\u30bd\u30c3\u30c9\u306b\u3066\u6307\u5b9a\u3057\u305f\u30d3\u30e5\u30fc\u3092\u8868\u793a\u3067\u304d\u308b\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4f8b\u5916\u30af\u30e9\u30b9\u3068\u30d3\u30e5\u30fc\u3092\u4f5c\u6210 \u4f8b\u5916\u30af\u30e9\u30b9\u3092\u6b21\u306e\u30b3\u30de\u30f3\u30c9\u3067\u4f5c\u6210\u3002 \u4f8b\u5916\u6642\u306b\u8868\u793a\u3059\u308b\u30d3\u30e5\u30fc\u3092\u4f5c\u6210\u3002 resources\/views\/exceptions\/exception.blade.php \u30d5\u30a1\u30a4\u30eb\u304c\u4f5c\u6210\u3055\u308c\u308b\u3002 \u4f8b\u5916\u30af\u30e9\u30b9 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[96],"tags":[88,81],"class_list":["post-1080","post","type-post","status-publish","format-standard","hentry","category-laravel","tag-laravel","tag-php"],"_links":{"self":[{"href":"https:\/\/shinke1987.net\/index.php?rest_route=\/wp\/v2\/posts\/1080","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/shinke1987.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/shinke1987.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/shinke1987.net\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/shinke1987.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1080"}],"version-history":[{"count":2,"href":"https:\/\/shinke1987.net\/index.php?rest_route=\/wp\/v2\/posts\/1080\/revisions"}],"predecessor-version":[{"id":1082,"href":"https:\/\/shinke1987.net\/index.php?rest_route=\/wp\/v2\/posts\/1080\/revisions\/1082"}],"wp:attachment":[{"href":"https:\/\/shinke1987.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1080"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/shinke1987.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1080"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/shinke1987.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1080"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}