{"id":30472,"date":"2025-09-28T07:40:56","date_gmt":"2025-09-28T04:40:56","guid":{"rendered":"https:\/\/fatihsoysal.com\/blog\/?p=30472"},"modified":"2025-09-28T07:40:56","modified_gmt":"2025-09-28T04:40:56","slug":"spring-mvcde-istisna-yonetimi-controlleradvice-exceptionhandler-ve-handlerexceptionresolver","status":"publish","type":"post","link":"https:\/\/fatihsoysal.com\/blog\/spring-mvcde-istisna-yonetimi-controlleradvice-exceptionhandler-ve-handlerexceptionresolver\/","title":{"rendered":"Spring MVC&#8217;de \u0130stisna Y\u00f6netimi: @ControllerAdvice, @ExceptionHandler ve HandlerExceptionResolver"},"content":{"rendered":"<p><body><\/p>\n<h2>Spring MVC&#8217;de \u0130stisna Y\u00f6netimi: @ControllerAdvice, @ExceptionHandler ve HandlerExceptionResolver<\/h2>\n<h2>Giri\u015f<\/h2>\n<p>Modern web uygulamalar\u0131, kullan\u0131c\u0131larla etkile\u015fim kurarken ve karma\u015f\u0131k i\u015f mant\u0131\u011f\u0131n\u0131 y\u00fcr\u00fct\u00fcrken \u00e7e\u015fitli hata ve istisna durumlar\u0131yla kar\u015f\u0131la\u015fabilir. Bu durumlar, beklenmedik veri giri\u015flerinden, a\u011f sorunlar\u0131na, veritaban\u0131 ba\u011flant\u0131 hatalar\u0131na veya i\u015f kurallar\u0131n\u0131n ihlallerine kadar geni\u015f bir yelpazeyi kapsar. Bir uygulaman\u0131n sa\u011flaml\u0131\u011f\u0131 ve kullan\u0131c\u0131 deneyimi, bu istisnalar\u0131n ne kadar etkili bir \u015fekilde y\u00f6netildi\u011fine ba\u011fl\u0131d\u0131r. Spring MVC, bu t\u00fcr senaryolar\u0131 ele almak i\u00e7in g\u00fc\u00e7l\u00fc ve esnek mekanizmalar sunar. Do\u011fru istisna y\u00f6netimi stratejileri uygulamak, uygulaman\u0131z\u0131n daha g\u00fcvenilir, bak\u0131m\u0131 daha kolay ve kullan\u0131c\u0131 dostu olmas\u0131n\u0131 sa\u011flar.<\/p>\n<p>Bu makalede, Spring MVC ekosisteminde istisna y\u00f6netiminin temel ta\u015flar\u0131 olan <code>@ExceptionHandler<\/code> anotasyonu, <code>@ControllerAdvice<\/code> anotasyonu ve <code>HandlerExceptionResolver<\/code> aray\u00fcz\u00fcn\u00fc derinlemesine inceleyece\u011fiz. Her bir yakla\u015f\u0131m\u0131n ne zaman kullan\u0131laca\u011f\u0131n\u0131, avantajlar\u0131n\u0131 ve dezavantajlar\u0131n\u0131 \u00f6rnek kodlarla a\u00e7\u0131klayacak, b\u00f6ylece geli\u015ftiricilerin uygulamalar\u0131nda en uygun stratejiyi se\u00e7melerine yard\u0131mc\u0131 olaca\u011f\u0131z. Amac\u0131m\u0131z, Spring MVC&#8217;deki istisna y\u00f6netiminin farkl\u0131 katmanlar\u0131n\u0131 ve bu katmanlar\u0131n nas\u0131l bir araya gelerek kapsaml\u0131 bir hata i\u015fleme \u00e7\u00f6z\u00fcm\u00fc sundu\u011funu net bir \u015fekilde ortaya koymakt\u0131r.<\/p>\n<h2>Temel \u0130stisna Y\u00f6netimi Kavramlar\u0131<\/h2>\n<p>\u0130stisna y\u00f6netimine dalmadan \u00f6nce, Java&#8217;daki temel istisna kavramlar\u0131n\u0131 ve web uygulamalar\u0131nda istisna y\u00f6netiminin neden bu kadar kritik oldu\u011funu anlamak \u00f6nemlidir.<\/p>\n<h3>Java&#8217;da \u0130stisnalar ve Hatalar<\/h3>\n<p>Java&#8217;da istisnalar (exceptions) ve hatalar (errors), program\u0131n normal ak\u0131\u015f\u0131n\u0131 bozan olaylar\u0131 temsil eder. <code>Throwable<\/code> s\u0131n\u0131f\u0131, t\u00fcm istisna ve hata s\u0131n\u0131flar\u0131n\u0131n s\u00fcper s\u0131n\u0131f\u0131d\u0131r.<br \/>\n*   <strong>Hatalar (Errors):<\/strong> Genellikle uygulaman\u0131n kontrol\u00fc d\u0131\u015f\u0131ndaki ciddi sorunlar\u0131 (\u00f6rn: <code>OutOfMemoryError<\/code>, <code>StackOverflowError<\/code>) temsil eder. Bu t\u00fcr durumlarda, uygulamay\u0131 kurtarmak genellikle m\u00fcmk\u00fcn de\u011fildir ve JVM&#8217;in kapanmas\u0131 gerekebilir. Geli\u015ftiricilerin do\u011frudan yakalay\u0131p i\u015flemeye \u00e7al\u0131\u015ft\u0131\u011f\u0131 durumlar de\u011fildir.<br \/>\n*   <strong>\u0130stisnalar (Exceptions):<\/strong> Uygulaman\u0131n \u00e7al\u0131\u015fmas\u0131 s\u0131ras\u0131nda meydana gelen ancak genellikle yakalan\u0131p i\u015flenebilecek sorunlar\u0131 temsil eder. \u0130stisnalar iki ana kategoriye ayr\u0131l\u0131r:<br \/>\n    *   <strong>Kontrol Edilen \u0130stisnalar (Checked Exceptions):<\/strong> <code>Exception<\/code> s\u0131n\u0131f\u0131ndan t\u00fcreyen ancak <code>RuntimeException<\/code> s\u0131n\u0131f\u0131ndan t\u00fcremeyen istisnalard\u0131r. Derleme zaman\u0131nda kontrol edilirler ve metot imzalar\u0131nda <code>throws<\/code> anahtar kelimesiyle belirtilmeli veya <code>try-catch<\/code> blo\u011fu ile yakalanmal\u0131d\u0131r. \u00d6rnek: <code>IOException<\/code>, <code>SQLException<\/code>.<br \/>\n    *   <strong>Kontrol Edilmeyen \u0130stisnalar (Unchecked Exceptions) veya \u00c7al\u0131\u015fma Zaman\u0131 \u0130stisnalar\u0131 (Runtime Exceptions):<\/strong> <code>RuntimeException<\/code> s\u0131n\u0131f\u0131ndan t\u00fcreyen istisnalard\u0131r. Derleme zaman\u0131nda kontrol edilmezler ve metot imzas\u0131nda belirtilmesi zorunlu de\u011fildir. Genellikle programc\u0131 hatalar\u0131n\u0131 (\u00f6rn: <code>NullPointerException<\/code>, <code>ArrayIndexOutOfBoundsException<\/code>, <code>IllegalArgumentException<\/code>) veya kurtar\u0131lamayacak mant\u0131ksal hatalar\u0131 g\u00f6sterirler. Spring MVC genellikle bu t\u00fcr istisnalarla daha s\u0131k kar\u015f\u0131la\u015f\u0131r.<\/p>\n<h3>Web Uygulamalar\u0131nda \u0130stisna Y\u00f6netiminin \u00d6nemi<\/h3>\n<p>Web uygulamalar\u0131nda istisna y\u00f6netimi sadece teknik bir gereklilik de\u011fil, ayn\u0131 zamanda kullan\u0131c\u0131 deneyimi, g\u00fcvenlik ve uygulama bak\u0131m\u0131 a\u00e7\u0131s\u0131ndan da hayati \u00f6neme sahiptir.<br \/>\n*   <strong>Kullan\u0131c\u0131 Deneyimi:<\/strong> Beklenmedik bir hata durumunda, kullan\u0131c\u0131ya anlams\u0131z bir y\u0131\u011f\u0131n izi (stack trace) g\u00f6stermek yerine, anla\u015f\u0131l\u0131r ve yard\u0131mc\u0131 bir hata mesaj\u0131 sunmak, uygulaman\u0131n profesyonel alg\u0131s\u0131n\u0131 art\u0131r\u0131r. Hatta bazen kullan\u0131c\u0131y\u0131 hatan\u0131n nas\u0131l d\u00fczeltilece\u011fi konusunda y\u00f6nlendirmek m\u00fcmk\u00fcnd\u00fcr.<br \/>\n*   <strong>G\u00fcvenlik:<\/strong> Y\u0131\u011f\u0131n izleri veya ayr\u0131nt\u0131l\u0131 hata mesajlar\u0131, sald\u0131rganlara uygulaman\u0131z\u0131n i\u00e7 yap\u0131s\u0131, kullan\u0131lan k\u00fct\u00fcphaneler veya veritaban\u0131 \u015femas\u0131 hakk\u0131nda hassas bilgiler sa\u011flayabilir. Do\u011fru istisna y\u00f6netimi, bu t\u00fcr bilgilerin a\u00e7\u0131\u011fa \u00e7\u0131kmas\u0131n\u0131 engeller.<br \/>\n*   <strong>Bak\u0131m Kolayl\u0131\u011f\u0131:<\/strong> Merkezi bir istisna y\u00f6netim mekanizmas\u0131, hatalar\u0131n tek bir yerden ele al\u0131nmas\u0131n\u0131, loglanmas\u0131n\u0131 ve izlenmesini sa\u011flar. Bu, sorun giderme ve hata ay\u0131klama s\u00fcre\u00e7lerini \u00f6nemli \u00f6l\u00e7\u00fcde h\u0131zland\u0131r\u0131r.<br \/>\n*   <strong>API Tutarl\u0131l\u0131\u011f\u0131:<\/strong> RESTful API&#8217;lar geli\u015ftirirken, hata yan\u0131tlar\u0131n\u0131n tutarl\u0131 bir formatta (\u00f6rn: JSON) ve anlaml\u0131 HTTP durum kodlar\u0131yla (\u00f6rn: 400 Bad Request, 404 Not Found, 500 Internal Server Error) d\u00f6nmesi, API&#8217;yi kullanan istemcilerin (frontend uygulamalar\u0131, mobil uygulamalar) hatalar\u0131 kolayca i\u015flemesini sa\u011flar.<\/p>\n<h2>Spring MVC&#8217;de \u0130stisna Y\u00f6netimine Genel Bak\u0131\u015f<\/h2>\n<p>Spring MVC, istisna y\u00f6netimi i\u00e7in \u00e7e\u015fitli seviyelerde ve esnekliklerde mekanizmalar sunar. Bu mekanizmalar, basit, controller&#8217;a \u00f6zg\u00fc hata i\u015fleminden, t\u00fcm uygulama genelinde ge\u00e7erli olacak karma\u015f\u0131k ve merkezi \u00e7\u00f6z\u00fcmlere kadar de\u011fi\u015fir. Spring&#8217;in bu konudaki felsefesi, geli\u015ftiricilere ihtiya\u00e7lar\u0131na en uygun arac\u0131 sa\u011flamakt\u0131r.<br \/>\n*   <strong>Controller Seviyesi:<\/strong> <code>@ExceptionHandler<\/code> anotasyonu ile belirli bir controller i\u00e7indeki metotlar taraf\u0131ndan f\u0131rlat\u0131lan istisnalar\u0131 yakalamak.<br \/>\n*   <strong>Global Seviye:<\/strong> <code>@ControllerAdvice<\/code> anotasyonu ile <code>@ExceptionHandler<\/code>&#8216;\u0131 birle\u015ftirerek t\u00fcm uygulama genelindeki controller&#8217;lar i\u00e7in merkezi bir istisna y\u00f6netim katman\u0131 olu\u015fturmak.<br \/>\n*   <strong>D\u00fc\u015f\u00fck Seviye\/Programatik:<\/strong> <code>HandlerExceptionResolver<\/code> aray\u00fcz\u00fcn\u00fc implemente ederek Spring&#8217;in istisna \u00e7\u00f6z\u00fcmleme mekanizmas\u0131na tam kontrolle m\u00fcdahale etmek. Bu, Spring&#8217;in kendi i\u00e7 istisna \u00e7\u00f6z\u00fcc\u00fclerinin (\u00f6rn: <code>DefaultHandlerExceptionResolver<\/code>, <code>SimpleMappingExceptionResolver<\/code>) temelidir.<\/p>\n<p>Bu yakla\u015f\u0131mlar\u0131n her birini detayl\u0131 olarak inceleyelim.<\/p>\n<h2>@ExceptionHandler Anotasyonu<\/h2>\n<p><code>@ExceptionHandler<\/code> anotasyonu, Spring MVC&#8217;de istisna y\u00f6netiminin en temel ve do\u011frudan yoludur. Belirli bir controller i\u00e7inde f\u0131rlat\u0131lan istisnalar\u0131 yakalamak ve i\u015flemek i\u00e7in kullan\u0131l\u0131r.<\/p>\n<h3>Controller Seviyesinde \u0130stisna Y\u00f6netimi<\/h3>\n<p>Bir <code>Controller<\/code> s\u0131n\u0131f\u0131 i\u00e7inde bir metodu <code>@ExceptionHandler<\/code> ile i\u015faretledi\u011finizde, bu metot sadece o controller i\u00e7indeki di\u011fer metotlar taraf\u0131ndan f\u0131rlat\u0131lan belirtilen istisna t\u00fcrlerini yakalar. Bu, belirli bir controller&#8217;\u0131n kendi \u00f6zel hata i\u015fleme mant\u0131\u011f\u0131na sahip olmas\u0131 gerekti\u011finde kullan\u0131\u015fl\u0131d\u0131r.<\/p>\n<p><strong>Nas\u0131l \u00c7al\u0131\u015f\u0131r:<\/strong><br \/>\n1.  Bir client bir HTTP iste\u011fi g\u00f6nderir.<br \/>\n2.  Spring MVC, iste\u011fi ilgili controller metoduna y\u00f6nlendirir.<br \/>\n3.  Controller metodu \u00e7al\u0131\u015f\u0131rken bir istisna f\u0131rlat\u0131r.<br \/>\n4.  Spring, ayn\u0131 controller i\u00e7inde bu istisna t\u00fcr\u00fcn\u00fc veya onun bir s\u00fcper s\u0131n\u0131f\u0131n\u0131 yakalamak i\u00e7in <code>@ExceptionHandler<\/code> ile i\u015faretlenmi\u015f bir metot olup olmad\u0131\u011f\u0131n\u0131 kontrol eder.<br \/>\n5.  E\u011fer uygun bir metot bulunursa, Spring bu metodu \u00e7a\u011f\u0131r\u0131r ve istisnay\u0131 ona iletir.<br \/>\n6.  <code>@ExceptionHandler<\/code> metodu, istisnay\u0131 i\u015fler ve uygun bir yan\u0131t (\u00f6rn: hata mesaj\u0131, HTTP durum kodu) d\u00f6nd\u00fcr\u00fcr.<\/p>\n<p><strong>Avantajlar\u0131:<\/strong><br \/>\n*   <strong>Basitlik:<\/strong> Belirli bir controller&#8217;a \u00f6zg\u00fc istisnalar\u0131 y\u00f6netmek i\u00e7in kolay ve anla\u015f\u0131l\u0131r bir yol sunar.<br \/>\n*   <strong>\u00d6zg\u00fcnl\u00fck:<\/strong> Her controller, kendi \u00f6zel istisna i\u015fleme mant\u0131\u011f\u0131na sahip olabilir.<\/p>\n<p><strong>Dezavantajlar\u0131:<\/strong><br \/>\n*   <strong>Tekrar:<\/strong> E\u011fer birden fazla controller ayn\u0131 istisna t\u00fcr\u00fcn\u00fc ayn\u0131 \u015fekilde ele almas\u0131 gerekiyorsa, <code>@ExceptionHandler<\/code> kodunu her controller&#8217;a kopyalamak zorunda kal\u0131rs\u0131n\u0131z. Bu, kod tekrar\u0131na (DRY &#8211; Don&#8217;t Repeat Yourself prensibinin ihlali) yol a\u00e7ar ve bak\u0131m\u0131 zorla\u015ft\u0131r\u0131r.<br \/>\n*   <strong>Genelle\u015ftirilemez:<\/strong> Uygulama genelindeki istisnalar\u0131 tek bir noktadan y\u00f6netmek i\u00e7in uygun de\u011fildir.<\/p>\n<h3>Birden Fazla \u0130stisna T\u00fcr\u00fcn\u00fc Yakalama<\/h3>\n<p>Bir <code>@ExceptionHandler<\/code> metodu, tek bir istisna t\u00fcr\u00fcn\u00fc veya bir istisna dizisini yakalayabilir. Bu, <code>value<\/code> veya <code>exception<\/code> \u00f6zniteli\u011fi kullan\u0131larak belirtilir.<\/p>\n<pre><code class=\"language-java\">@ExceptionHandler({ MyCustomException.class, AnotherCustomException.class })\npublic ResponseEntity<String> handleMultipleExceptions(Exception ex) {\n    \/\/ \u0130stisnay\u0131 i\u015fle ve yan\u0131t d\u00f6nd\u00fcr\n    return new ResponseEntity<>(\"Birden fazla istisna t\u00fcr\u00fc yakaland\u0131: \" + ex.getMessage(), HttpStatus.BAD_REQUEST);\n}<\/code><\/pre>\n<h3>\u00d6rnek Kod<\/h3>\n<p>A\u015fa\u011f\u0131daki \u00f6rnek, bir <code>ProductController<\/code> i\u00e7inde <code>ProductNotFoundException<\/code> istisnas\u0131n\u0131 nas\u0131l yakalayaca\u011f\u0131n\u0131z\u0131 g\u00f6sterir:<\/p>\n<pre><code class=\"language-java\">package com.example.demo.controller;\n\nimport com.example.demo.exception.ProductNotFoundException;\nimport com.example.demo.model.Product;\nimport org.springframework.http.HttpStatus;\nimport org.springframework.http.ResponseEntity;\nimport org.springframework.web.bind.annotation.*;\n\nimport java.util.ArrayList;\nimport java.util.List;\nimport java.util.Optional;\n\n@RestController\n@RequestMapping(\"\/products\")\npublic class ProductController {\n\n    private List<Product> products = new ArrayList<>();\n\n    public ProductController() {\n        products.add(new Product(1L, \"Laptop\", 1200.0));\n        products.add(new Product(2L, \"Mouse\", 25.0));\n    }\n\n    @GetMapping(\"\/{id}\")\n    public ResponseEntity<Product> getProductById(@PathVariable Long id) {\n        Optional<Product> product = products.stream()\n                .filter(p -> p.getId().equals(id))\n                .findFirst();\n\n        if (product.isPresent()) {\n            return ResponseEntity.ok(product.get());\n        } else {\n            throw new ProductNotFoundException(\"ID \" + id + \" ile \u00fcr\u00fcn bulunamad\u0131.\");\n        }\n    }\n\n    \/\/ Bu controller'a \u00f6zg\u00fc ProductNotFoundException'\u0131 yakalayan metot\n    @ExceptionHandler(ProductNotFoundException.class)\n    public ResponseEntity<String> handleProductNotFoundException(ProductNotFoundException ex) {\n        return new ResponseEntity<>(ex.getMessage(), HttpStatus.NOT_FOUND);\n    }\n\n    \/\/ Genel bir istisnay\u0131 yakalayan metot (daha spesifik olanlar \u00f6nce yakalan\u0131r)\n    @ExceptionHandler(Exception.class)\n    public ResponseEntity<String> handleGenericException(Exception ex) {\n        return new ResponseEntity<>(\"Bir hata olu\u015ftu: \" + ex.getMessage(), HttpStatus.INTERNAL_SERVER_ERROR);\n    }\n}<\/code><\/pre>\n<pre><code class=\"language-java\">\/\/ Product.java\npackage com.example.demo.model;\n\npublic class Product {\n    private Long id;\n    private String name;\n    private double price;\n\n    public Product(Long id, String name, double price) {\n        this.id = id;\n        this.name = name;\n        this.price = price;\n    }\n\n    \/\/ Getters and setters\n    public Long getId() { return id; }\n    public void setId(Long id) { this.id = id; }\n    public String getName() { return name; }\n    public void setName(String name) { this.name = name; }\n    public double getPrice() { return price; }\n    public void setPrice(double price) { this.price = price; }\n}<\/code><\/pre>\n<pre><code class=\"language-java\">\/\/ ProductNotFoundException.java\npackage com.example.demo.exception;\n\npublic class ProductNotFoundException extends RuntimeException {\n    public ProductNotFoundException(String message) {\n        super(message);\n    }\n}<\/code><\/pre>\n<p>Yukar\u0131daki \u00f6rnekte, <code>\/products\/3<\/code> adresine yap\u0131lan bir istek, <code>ProductNotFoundException<\/code> f\u0131rlatacak ve bu istisna <code>handleProductNotFoundException<\/code> metodu taraf\u0131ndan yakalanarak 404 NOT FOUND durum koduyla bir yan\u0131t d\u00f6necektir.<\/p>\n<h2>@ControllerAdvice Anotasyonu<\/h2>\n<p><code>@ExceptionHandler<\/code> anotasyonunun controller seviyesindeki s\u0131n\u0131rlamalar\u0131n\u0131 a\u015fmak ve uygulama genelinde merkezi bir istisna y\u00f6netim mekanizmas\u0131 olu\u015fturmak i\u00e7in Spring, <code>@ControllerAdvice<\/code> anotasyonunu sunar.<\/p>\n<h3>Global \u0130stisna Y\u00f6netimi \u00c7\u00f6z\u00fcm\u00fc<\/h3>\n<p><code>@ControllerAdvice<\/code> anotasyonu, Spring&#8217;in bile\u015fen taramas\u0131 s\u0131ras\u0131nda ke\u015ffedilen ve t\u00fcm uygulamadaki controller&#8217;lar i\u00e7in ortak \u00f6zellikler (istisna y\u00f6netimi, veri ba\u011flama, model \u00f6znitelikleri) tan\u0131mlayan bir s\u0131n\u0131f\u0131 i\u015faretlemek i\u00e7in kullan\u0131l\u0131r. \u00d6zellikle istisna y\u00f6netimi ba\u011flam\u0131nda, <code>@ControllerAdvice<\/code> ile i\u015faretlenmi\u015f bir s\u0131n\u0131f i\u00e7inde tan\u0131mlanan <code>@ExceptionHandler<\/code> metotlar\u0131, t\u00fcm uygulama genelindeki controller&#8217;lar taraf\u0131ndan f\u0131rlat\u0131lan istisnalar\u0131 yakalayabilir.<\/p>\n<p><strong>Nas\u0131l \u00c7al\u0131\u015f\u0131r:<\/strong><br \/>\n1.  Bir <code>@ControllerAdvice<\/code> s\u0131n\u0131f\u0131 olu\u015fturulur.<br \/>\n2.  Bu s\u0131n\u0131f\u0131n i\u00e7ine, bir controller&#8217;daki gibi <code>@ExceptionHandler<\/code> ile i\u015faretlenmi\u015f metotlar tan\u0131mlan\u0131r.<br \/>\n3.  Uygulaman\u0131n herhangi bir yerindeki bir controller metodu bir istisna f\u0131rlatt\u0131\u011f\u0131nda, Spring \u00f6nce o controller i\u00e7indeki <code>@ExceptionHandler<\/code>&#8216;lar\u0131 arar.<br \/>\n4.  E\u011fer controller i\u00e7inde uygun bir i\u015fleyici bulunamazsa, Spring <code>@ControllerAdvice<\/code> ile i\u015faretlenmi\u015f s\u0131n\u0131flardaki <code>@ExceptionHandler<\/code> metotlar\u0131n\u0131 arar.<br \/>\n5.  Uygun bir metot bulunursa, istisna o metot taraf\u0131ndan i\u015flenir.<\/p>\n<p><strong>Avantajlar\u0131:<\/strong><br \/>\n*   <strong>Merkezi Y\u00f6netim (DRY):<\/strong> T\u00fcm uygulama genelindeki istisnalar\u0131 tek bir yerden y\u00f6netmenizi sa\u011flar, kod tekrar\u0131n\u0131 \u00f6nler.<br \/>\n*   <strong>Temiz Kod:<\/strong> Controller&#8217;lar\u0131n i\u015f mant\u0131\u011f\u0131 ve istisna i\u015fleme mant\u0131\u011f\u0131 ayr\u0131 tutularak daha temiz ve okunakl\u0131 bir kod yap\u0131s\u0131 elde edilir.<br \/>\n*   <strong>Tutarl\u0131l\u0131k:<\/strong> T\u00fcm hata yan\u0131tlar\u0131n\u0131n ayn\u0131 formatta ve HTTP durum kodlar\u0131yla d\u00f6nmesini sa\u011flayarak API tutarl\u0131l\u0131\u011f\u0131n\u0131 art\u0131r\u0131r.<br \/>\n*   <strong>Esneklik:<\/strong> Belirli istisna t\u00fcrleri i\u00e7in \u00f6zel yan\u0131tlar veya loglama mekanizmalar\u0131 tan\u0131mlamak kolayd\u0131r.<\/p>\n<h3>@ExceptionHandler ile Birlikte Kullan\u0131m\u0131<\/h3>\n<p><code>@ControllerAdvice<\/code> tek ba\u015f\u0131na istisna y\u00f6netimi yapmaz; <code>@ExceptionHandler<\/code> anotasyonlu metotlar\u0131 bar\u0131nd\u0131rmak i\u00e7in bir konteyner g\u00f6revi g\u00f6r\u00fcr. Bu, bir <code>GlobalExceptionHandler<\/code> s\u0131n\u0131f\u0131 olu\u015fturup i\u00e7ine \u00e7e\u015fitli <code>@ExceptionHandler<\/code> metotlar\u0131 ekleyerek yap\u0131l\u0131r.<\/p>\n<pre><code class=\"language-java\">package com.example.demo.exception;\n\nimport org.springframework.http.HttpStatus;\nimport org.springframework.http.ResponseEntity;\nimport org.springframework.web.bind.MethodArgumentNotValidException;\nimport org.springframework.web.bind.annotation.ControllerAdvice;\nimport org.springframework.web.bind.annotation.ExceptionHandler;\nimport org.springframework.web.context.request.WebRequest;\n\nimport java.time.LocalDateTime;\nimport java.util.HashMap;\nimport java.util.Map;\n\n@ControllerAdvice\npublic class GlobalExceptionHandler {\n\n    @ExceptionHandler(ProductNotFoundException.class)\n    public ResponseEntity<ErrorDetails> handleProductNotFoundException(ProductNotFoundException ex, WebRequest request) {\n        ErrorDetails errorDetails = new ErrorDetails(LocalDateTime.now(), ex.getMessage(), request.getDescription(false));\n        return new ResponseEntity<>(errorDetails, HttpStatus.NOT_FOUND);\n    }\n\n    @ExceptionHandler(IllegalArgumentException.class)\n    public ResponseEntity<ErrorDetails> handleIllegalArgumentException(IllegalArgumentException ex, WebRequest request) {\n        ErrorDetails errorDetails = new ErrorDetails(LocalDateTime.now(), ex.getMessage(), request.getDescription(false));\n        return new ResponseEntity<>(errorDetails, HttpStatus.BAD_REQUEST);\n    }\n\n    @ExceptionHandler(MethodArgumentNotValidException.class)\n    public ResponseEntity<Object> handleValidationExceptions(MethodArgumentNotValidException ex, WebRequest request) {\n        Map<String, String> errors = new HashMap<>();\n        ex.getBindingResult().getFieldErrors().forEach(error ->\n                errors.put(error.getField(), error.getDefaultMessage()));\n        ErrorDetails errorDetails = new ErrorDetails(LocalDateTime.now(), \"Do\u011frulama Hatas\u0131\", errors.toString());\n        return new ResponseEntity<>(errorDetails, HttpStatus.BAD_REQUEST);\n    }\n\n    \/\/ Di\u011fer t\u00fcm istisnalar\u0131 yakalayan genel i\u015fleyici\n    @ExceptionHandler(Exception.class)\n    public ResponseEntity<ErrorDetails> handleGlobalException(Exception ex, WebRequest request) {\n        ErrorDetails errorDetails = new ErrorDetails(LocalDateTime.now(), \"Beklenmeyen bir hata olu\u015ftu: \" + ex.getMessage(), request.getDescription(false));\n        return new ResponseEntity<>(errorDetails, HttpStatus.INTERNAL_SERVER_ERROR);\n    }\n}<\/code><\/pre>\n<pre><code class=\"language-java\">\/\/ ErrorDetails.java - Hata yan\u0131t\u0131 i\u00e7in model\npackage com.example.demo.exception;\n\nimport java.time.LocalDateTime;\n\npublic class ErrorDetails {\n    private LocalDateTime timestamp;\n    private String message;\n    private String details;\n\n    public ErrorDetails(LocalDateTime timestamp, String message, String details) {\n        this.timestamp = timestamp;\n        this.message = message;\n        this.details = details;\n    }\n\n    \/\/ Getters\n    public LocalDateTime getTimestamp() { return timestamp; }\n    public String getMessage() { return message; }\n    public String getDetails() { return details; }\n}<\/code><\/pre>\n<p>Bu <code>GlobalExceptionHandler<\/code> s\u0131n\u0131f\u0131, uygulaman\u0131zdaki herhangi bir controller&#8217;dan f\u0131rlat\u0131lan <code>ProductNotFoundException<\/code>, <code>IllegalArgumentException<\/code>, <code>MethodArgumentNotValidException<\/code> ve di\u011fer t\u00fcm <code>Exception<\/code> t\u00fcrlerini merkezi olarak ele alacakt\u0131r.<\/p>\n<h3>Hedef Kapsam\u0131n\u0131 Belirleme (@ControllerAdvice&#8217;\u0131n \u00d6zellikleri)<\/h3>\n<p><code>@ControllerAdvice<\/code> anotasyonu, hangi controller&#8217;lar i\u00e7in ge\u00e7erli olaca\u011f\u0131n\u0131 belirlemek \u00fczere \u00e7e\u015fitli \u00f6znitelikler sunar:<br \/>\n*   <strong><code>annotations()<\/code>:<\/strong> Sadece belirtilen anotasyonlara sahip controller&#8217;lar i\u00e7in ge\u00e7erli olur. \u00d6rne\u011fin, <code>@ControllerAdvice(annotations = RestController.class)<\/code> sadece <code>@RestController<\/code> ile i\u015faretlenmi\u015f controller&#8217;lar i\u00e7in ge\u00e7erli olacakt\u0131r.<br \/>\n*   <strong><code>basePackages()<\/code> (veya <code>value()<\/code>):<\/strong> Sadece belirtilen paketler i\u00e7indeki controller&#8217;lar i\u00e7in ge\u00e7erli olur. \u00d6rne\u011fin, <code>@ControllerAdvice(basePackages = \"com.example.demo.controller\")<\/code> sadece bu paketteki controller&#8217;lar i\u00e7in istisnalar\u0131 i\u015fler.<br \/>\n*   <strong><code>assignableTypes()<\/code>:<\/strong> Sadece belirtilen t\u00fcrlerden t\u00fcreyen veya bu t\u00fcrleri implemente eden controller&#8217;lar i\u00e7in ge\u00e7erli olur.<\/p>\n<p>Bu \u00f6zellikler, uygulaman\u0131zda farkl\u0131 mod\u00fcller veya ba\u011flamlar i\u00e7in farkl\u0131 istisna i\u015fleme stratejileri uygulamak istedi\u011finizde olduk\u00e7a kullan\u0131\u015fl\u0131d\u0131r. \u00c7o\u011fu durumda, t\u00fcm uygulama genelinde ge\u00e7erli olmas\u0131 i\u00e7in herhangi bir \u00f6znitelik belirtilmeden <code>@ControllerAdvice<\/code> kullan\u0131lmas\u0131 yeterlidir.<\/p>\n<h2>HandlerExceptionResolver Aray\u00fcz\u00fc<\/h2>\n<p>Spring MVC&#8217;deki <code>@ExceptionHandler<\/code> ve <code>@ControllerAdvice<\/code> anotasyonlar\u0131, <code>HandlerExceptionResolver<\/code> aray\u00fcz\u00fcn\u00fcn \u00fczerine in\u015fa edilmi\u015f y\u00fcksek seviyeli soyutlamalard\u0131r. Bu aray\u00fcz, Spring&#8217;in istisna y\u00f6netiminin temelini olu\u015fturur ve Spring MVC&#8217;nin istisnalar\u0131 nas\u0131l i\u015fledi\u011fine dair en d\u00fc\u015f\u00fck seviyeli kontrol\u00fc sa\u011flar.<\/p>\n<h3>Spring&#8217;in Temel \u0130stisna \u00c7\u00f6z\u00fcmleme Mekanizmas\u0131<\/h3>\n<p>Bir istisna f\u0131rlat\u0131ld\u0131\u011f\u0131nda, Spring&#8217;in <code>DispatcherServlet<\/code>&#8216;i bu istisnay\u0131 yakalar ve kay\u0131tl\u0131 t\u00fcm <code>HandlerExceptionResolver<\/code>&#8216;lar\u0131 s\u0131rayla \u00e7a\u011f\u0131rarak istisnay\u0131 \u00e7\u00f6zmeye \u00e7al\u0131\u015f\u0131r. Her \u00e7\u00f6z\u00fcc\u00fc, istisnay\u0131 i\u015fleyip bir <code>ModelAndView<\/code> d\u00f6nd\u00fcrebilir veya istisnay\u0131 i\u015flemeyi reddederek <code>null<\/code> d\u00f6nd\u00fcrebilir, bu durumda bir sonraki \u00e7\u00f6z\u00fcc\u00fcye ge\u00e7ilir.<\/p>\n<p>Spring, varsay\u0131lan olarak birka\u00e7 <code>HandlerExceptionResolver<\/code> implementasyonu sa\u011flar:<br \/>\n*   <strong><code>DefaultHandlerExceptionResolver<\/code>:<\/strong> Spring MVC&#8217;nin kendisi taraf\u0131ndan f\u0131rlat\u0131lan bir\u00e7ok standart istisnay\u0131 (\u00f6rn: <code>HttpRequestMethodNotSupportedException<\/code>, <code>MissingServletRequestParameterException<\/code>, <code>TypeMismatchException<\/code>) ele al\u0131r ve uygun HTTP durum kodlar\u0131na d\u00f6n\u00fc\u015ft\u00fcr\u00fcr.<br \/>\n*   <strong><code>ExceptionHandlerExceptionResolver<\/code>:<\/strong> Bu \u00e7\u00f6z\u00fcc\u00fc, <code>@ExceptionHandler<\/code> ve <code>@ControllerAdvice<\/code> anotasyonlar\u0131n\u0131 i\u015fleyen mekanizmad\u0131r. Yani, <code>@ControllerAdvice<\/code> ve <code>@ExceptionHandler<\/code> kullan\u0131rken asl\u0131nda bu <code>ExceptionHandlerExceptionResolver<\/code> devreye girer.<br \/>\n*   <strong><code>ResponseStatusExceptionResolver<\/code>:<\/strong> <code>@ResponseStatus<\/code> anotasyonuyla i\u015faretlenmi\u015f istisnalar\u0131 i\u015fler. Bir istisna s\u0131n\u0131f\u0131n\u0131 <code>@ResponseStatus(HttpStatus.NOT_FOUND)<\/code> gibi i\u015faretledi\u011finizde, bu \u00e7\u00f6z\u00fcc\u00fc devreye girer.<br \/>\n*   <strong><code>SimpleMappingExceptionResolver<\/code>:<\/strong> Bir istisna t\u00fcr\u00fcn\u00fc belirli bir hata g\u00f6r\u00fcn\u00fcm\u00fcne (view) e\u015flemek i\u00e7in kullan\u0131labilen yap\u0131land\u0131r\u0131labilir bir \u00e7\u00f6z\u00fcc\u00fcd\u00fcr. Genellikle geleneksel MVC uygulamalar\u0131nda hata sayfalar\u0131n\u0131 g\u00f6stermek i\u00e7in kullan\u0131l\u0131r.<\/p>\n<h3>\u00d6zel HandlerExceptionResolver Uygulamalar\u0131<\/h3>\n<p>\u00c7o\u011fu durumda, <code>@ControllerAdvice<\/code> ve <code>@ExceptionHandler<\/code> kombinasyonu yeterli olacakt\u0131r. Ancak, \u00e7ok \u00f6zel veya karma\u015f\u0131k istisna i\u015fleme gereksinimleriniz oldu\u011funda, kendi <code>HandlerExceptionResolver<\/code> implementasyonunuzu yazman\u0131z gerekebilir. Bu, a\u015fa\u011f\u0131daki senaryolarda faydal\u0131 olabilir:<br \/>\n*   <strong>Daha d\u00fc\u015f\u00fck seviyeli kontrol:<\/strong> Spring&#8217;in istisna i\u015fleme ak\u0131\u015f\u0131na tam olarak m\u00fcdahale etmek istedi\u011finizde.<br \/>\n*   <strong>Harici sistemlerle entegrasyon:<\/strong> \u0130stisnalar\u0131 \u00f6zel bir loglama sistemine, izleme arac\u0131na veya hata bildirim servisine g\u00f6ndermek istedi\u011finizde.<br \/>\n*   <strong>Farkl\u0131 g\u00f6r\u00fcn\u00fcm (view) \u00e7\u00f6z\u00fcmleri:<\/strong> \u0130stisna t\u00fcr\u00fcne g\u00f6re farkl\u0131 JSP sayfalar\u0131, Thymeleaf \u015fablonlar\u0131 veya di\u011fer g\u00f6r\u00fcn\u00fcm teknolojileri d\u00f6nd\u00fcrmeniz gerekti\u011finde.<br \/>\n*   <strong>\u00c7oklu istisna y\u00f6netimi stratejileri:<\/strong> Uygulaman\u0131z\u0131n farkl\u0131 b\u00f6l\u00fcmleri i\u00e7in tamamen farkl\u0131 istisna i\u015fleme mant\u0131\u011f\u0131na sahip olmak istedi\u011finizde.<\/p>\n<h3>HandlerExceptionResolver&#8217;\u0131n \u00c7al\u0131\u015fma Prensibi<\/h3>\n<p><code>HandlerExceptionResolver<\/code> aray\u00fcz\u00fc tek bir metot tan\u0131mlar:<\/p>\n<pre><code class=\"language-java\">public interface HandlerExceptionResolver {\n    ModelAndView resolveException(\n            HttpServletRequest request,\n            HttpServletResponse response,\n            Object handler,\n            Exception ex);\n}<\/code><\/pre>\n<p>*   <code>request<\/code>: \u0130stek nesnesi.<br \/>\n*   <code>response<\/code>: Yan\u0131t nesnesi.<br \/>\n*   <code>handler<\/code>: \u0130stisnay\u0131 f\u0131rlatan i\u015fleyici (genellikle controller metodu).<br \/>\n*   <code>ex<\/code>: F\u0131rlat\u0131lan istisna.<\/p>\n<p>Bu metot, istisnay\u0131 i\u015fleyip bir <code>ModelAndView<\/code> d\u00f6nd\u00fcrebilir. E\u011fer istisnay\u0131 ba\u015far\u0131yla i\u015fler ve bir g\u00f6r\u00fcn\u00fcm d\u00f6nd\u00fcrmek istiyorsan\u0131z, bir <code>ModelAndView<\/code> nesnesi d\u00f6nd\u00fcr\u00fcn. E\u011fer istisnay\u0131 i\u015flemeyi reddediyorsan\u0131z veya ba\u015fka bir \u00e7\u00f6z\u00fcc\u00fcn\u00fcn i\u015flemesini istiyorsan\u0131z <code>null<\/code> d\u00f6nd\u00fcr\u00fcn.<\/p>\n<h3>\u00d6rnek Kod<\/h3>\n<p>A\u015fa\u011f\u0131da, \u00f6zel bir <code>HandlerExceptionResolver<\/code> \u00f6rne\u011fi verilmi\u015ftir. Bu \u00f6rnek, bir istisna f\u0131rlat\u0131ld\u0131\u011f\u0131nda \u00f6zel bir hata sayfas\u0131n\u0131 (veya REST API i\u00e7in JSON yan\u0131t\u0131n\u0131) d\u00f6nd\u00fcrmek yerine, sadece loglama yap\u0131p Spring&#8217;in di\u011fer \u00e7\u00f6z\u00fcc\u00fclerinin devreye girmesine izin verebilir veya tamamen farkl\u0131 bir yan\u0131t \u00fcretebilir.<\/p>\n<pre><code class=\"language-java\">package com.example.demo.resolver;\n\nimport jakarta.servlet.http.HttpServletRequest;\nimport jakarta.servlet.http.HttpServletResponse;\nimport org.slf4j.Logger;\nimport org.slf4j.LoggerFactory;\nimport org.springframework.stereotype.Component;\nimport org.springframework.web.servlet.HandlerExceptionResolver;\nimport org.springframework.web.servlet.ModelAndView;\nimport org.springframework.web.servlet.view.json.MappingJackson2JsonView;\n\nimport java.util.HashMap;\nimport java.util.Map;\n\n@Component\npublic class CustomExceptionHandlerResolver implements HandlerExceptionResolver {\n\n    private static final Logger logger = LoggerFactory.getLogger(CustomExceptionHandlerResolver.class);\n\n    @Override\n    public ModelAndView resolveException(\n            HttpServletRequest request,\n            HttpServletResponse response,\n            Object handler,\n            Exception ex) {\n\n        logger.error(\"CustomExceptionHandlerResolver taraf\u0131ndan yakalanan istisna: \" + ex.getMessage(), ex);\n\n        \/\/ E\u011fer bu bir REST API iste\u011fiyse, JSON yan\u0131t\u0131 d\u00f6nd\u00fcrebiliriz\n        if (request.getHeader(\"Accept\") != null && request.getHeader(\"Accept\").contains(\"application\/json\")) {\n            response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); \/\/ 500 Internal Server Error\n\n            MappingJackson2JsonView jsonView = new MappingJackson2JsonView();\n            Map<String, Object> model = new HashMap<>();\n            model.put(\"error\", \"\u00d6zel Resolver Hatas\u0131\");\n            model.put(\"message\", \"Beklenmeyen bir hata olu\u015ftu: \" + ex.getMessage());\n            model.put(\"timestamp\", System.currentTimeMillis());\n\n            return new ModelAndView(jsonView, model);\n        } else {\n            \/\/ Web uygulamalar\u0131 i\u00e7in hata sayfas\u0131na y\u00f6nlendirebiliriz\n            \/\/ response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);\n            \/\/ return new ModelAndView(\"error-page\"); \/\/ error-page.html veya .jsp\n            \n            \/\/ \u0130stisnay\u0131 ba\u015fka bir \u00e7\u00f6z\u00fcc\u00fcye b\u0131rakmak i\u00e7in null d\u00f6nd\u00fcr\n            return null;\n        }\n    }\n}<\/code><\/pre>\n<p>Bu \u00f6zel \u00e7\u00f6z\u00fcc\u00fcy\u00fc etkinle\u015ftirmek i\u00e7in, Spring yap\u0131land\u0131rman\u0131za eklemeniz gerekebilir, ancak <code>@Component<\/code> anotasyonu sayesinde Spring Boot uygulamalar\u0131nda otomatik olarak alg\u0131lan\u0131p kaydedilecektir. Bu \u00f6rnek, istisnay\u0131 loglarken ayn\u0131 zamanda iste\u011fin <code>Accept<\/code> ba\u015fl\u0131\u011f\u0131na g\u00f6re farkl\u0131 yan\u0131tlar d\u00f6nd\u00fcrme potansiyelini g\u00f6stermektedir.<\/p>\n<h2>Farkl\u0131 \u0130stisna Y\u00f6netimi Yakla\u015f\u0131mlar\u0131n\u0131n Kar\u015f\u0131la\u015ft\u0131r\u0131lmas\u0131<\/h2>\n<p>Spring MVC&#8217;de istisna y\u00f6netimi i\u00e7in \u00fc\u00e7 ana yakla\u015f\u0131m\u0131 inceledik. \u015eimdi bu yakla\u015f\u0131mlar\u0131 ne zaman ve neden kullanaca\u011f\u0131m\u0131za dair bir kar\u015f\u0131la\u015ft\u0131rma yapal\u0131m.<\/p>\n<h3>@ExceptionHandler (Controller Seviyesi)<\/h3>\n<p>*   <strong>Avantajlar\u0131:<\/strong><br \/>\n    *   Belirli bir controller&#8217;a \u00f6zg\u00fc, basit istisna senaryolar\u0131 i\u00e7in h\u0131zl\u0131 ve kolay \u00e7\u00f6z\u00fcm.<br \/>\n    *   Controller&#8217;\u0131n kendi i\u00e7inde kalmas\u0131 nedeniyle yerel ba\u011flamda anla\u015f\u0131lmas\u0131 kolayd\u0131r.<br \/>\n*   <strong>Dezavantajlar\u0131:<\/strong><br \/>\n    *   Kod tekrar\u0131na yol a\u00e7ar; ayn\u0131 istisna t\u00fcr\u00fc farkl\u0131 controller&#8217;larda ayn\u0131 \u015fekilde i\u015flenecekse her birine ayr\u0131 ayr\u0131 yaz\u0131lmal\u0131d\u0131r.<br \/>\n    *   Uygulama genelinde tutarl\u0131 bir hata yan\u0131t\u0131 format\u0131 sa\u011flamak zordur.<br \/>\n*   <strong>Ne Zaman Kullan\u0131l\u0131r:<\/strong> Sadece tek bir controller&#8217;da ortaya \u00e7\u0131kan ve ba\u015fka hi\u00e7bir yerde i\u015flenmesi gerekmeyen \u00e7ok \u00f6zel bir istisna t\u00fcr\u00fc oldu\u011funda veya h\u0131zl\u0131 prototipleme yaparken. Nadiren tercih edilmelidir.<\/p>\n<h3>@ControllerAdvice + @ExceptionHandler (Global)<\/h3>\n<p>*   <strong>Avantajlar\u0131:<\/strong><br \/>\n    *   <strong>Merkezi \u0130stisna Y\u00f6netimi:<\/strong> T\u00fcm uygulama genelindeki istisnalar\u0131 tek bir yerden y\u00f6netir. Bu, kod tekrar\u0131n\u0131 ortadan kald\u0131r\u0131r ve bak\u0131m\u0131 kolayla\u015ft\u0131r\u0131r.<br \/>\n    *   <strong>Tutarl\u0131l\u0131k:<\/strong> T\u00fcm API&#8217;ler i\u00e7in standart ve tutarl\u0131 bir hata yan\u0131t\u0131 format\u0131 (\u00f6rn: JSON) sa\u011flamay\u0131 kolayla\u015ft\u0131r\u0131r.<br \/>\n    *   <strong>Temiz Controller&#8217;lar:<\/strong> Controller&#8217;lar\u0131n sadece i\u015f mant\u0131\u011f\u0131na odaklanmas\u0131n\u0131 sa\u011flar, istisna i\u015fleme detaylar\u0131n\u0131 onlardan ay\u0131r\u0131r.<br \/>\n    *   <strong>Esneklik:<\/strong> Belirli istisna t\u00fcrleri i\u00e7in \u00f6zelle\u015ftirilmi\u015f hata mesajlar\u0131 ve HTTP durum kodlar\u0131 d\u00f6nd\u00fcrmek kolayd\u0131r.<br \/>\n*   <strong>Dezavantajlar\u0131:<\/strong><br \/>\n    *   \u00c7ok k\u00fc\u00e7\u00fck, tek controller&#8217;l\u0131 uygulamalar i\u00e7in biraz fazla soyutlama gibi g\u00f6r\u00fcnebilir (ancak yine de \u00f6nerilir).<br \/>\n    *   Belirli bir controller&#8217;\u0131n istisnay\u0131 kendi \u00f6zel y\u00f6ntemleriyle ele almas\u0131n\u0131 engellemez, ancak <code>@ControllerAdvice<\/code>&#8216;daki i\u015fleyiciler, controller&#8217;daki i\u015fleyicilerden sonra devreye girer.<br \/>\n*   <strong>Ne Zaman Kullan\u0131l\u0131r:<\/strong> Modern Spring Boot ve RESTful API geli\u015ftirmenin standart ve en \u00e7ok \u00f6nerilen yoludur. Uygulaman\u0131z\u0131n boyutu ne olursa olsun, tutarl\u0131 ve s\u00fcrd\u00fcr\u00fclebilir bir istisna y\u00f6netimi i\u00e7in bu yakla\u015f\u0131m tercih edilmelidir.<\/p>\n<h3>HandlerExceptionResolver (Daha D\u00fc\u015f\u00fck Seviye)<\/h3>\n<p>*   <strong>Avantajlar\u0131:<\/strong><br \/>\n    *   <strong>Tam Kontrol:<\/strong> Spring&#8217;in istisna i\u015fleme ak\u0131\u015f\u0131na en d\u00fc\u015f\u00fck seviyede ve en kapsaml\u0131 \u015fekilde m\u00fcdahale etme olana\u011f\u0131 sunar.<br \/>\n    *   <strong>Geli\u015fmi\u015f Senaryolar:<\/strong> \u00d6zel loglama, harici sistem entegrasyonlar\u0131, istisna t\u00fcr\u00fcne g\u00f6re farkl\u0131 g\u00f6r\u00fcn\u00fcm d\u00f6nd\u00fcrme gibi karma\u015f\u0131k ve \u00f6zelle\u015ftirilmi\u015f senaryolar i\u00e7in idealdir.<br \/>\n    *   Spring&#8217;in varsay\u0131lan istisna i\u015fleme mekanizmalar\u0131n\u0131 geni\u015fletmek veya de\u011fi\u015ftirmek i\u00e7in kullan\u0131l\u0131r.<br \/>\n*   <strong>Dezavantajlar\u0131:<\/strong><br \/>\n    *   <strong>Karma\u015f\u0131kl\u0131k:<\/strong> <code>@ControllerAdvice<\/code>&#8216;a g\u00f6re daha fazla kod yazmay\u0131 ve Spring&#8217;in i\u00e7 i\u015fleyi\u015fi hakk\u0131nda daha derin bilgi sahibi olmay\u0131 gerektirir.<br \/>\n    *   <strong>Genellikle Gerek Duyulmaz:<\/strong> \u00c7o\u011fu uygulama i\u00e7in <code>@ControllerAdvice<\/code> yeterli oldu\u011fundan, bu seviyeye inmek nadiren gereklidir.<br \/>\n*   <strong>Ne Zaman Kullan\u0131l\u0131r:<\/strong> Standart Spring mekanizmalar\u0131n\u0131n yetersiz kald\u0131\u011f\u0131, \u00e7ok \u00f6zel ve d\u00fc\u015f\u00fck seviyeli istisna i\u015fleme mant\u0131\u011f\u0131na ihtiya\u00e7 duyuldu\u011fu durumlarda. \u00d6rne\u011fin, farkl\u0131 istisna t\u00fcrleri i\u00e7in tamamen farkl\u0131 hata sayfalar\u0131 g\u00f6stermeniz veya istisnalar\u0131 \u00f6zel bir \u015fekilde harici bir sisteme raporlaman\u0131z gerekti\u011finde.<\/p>\n<p><strong>\u00d6zetle, \u00e7o\u011fu geli\u015ftirici i\u00e7in <code>@ControllerAdvice<\/code> ile <code>@ExceptionHandler<\/code> kombinasyonu, Spring MVC&#8217;de istisna y\u00f6netiminin alt\u0131n standard\u0131d\u0131r.<\/strong> Bu yakla\u015f\u0131m, temiz, merkezi ve s\u00fcrd\u00fcr\u00fclebilir bir \u00e7\u00f6z\u00fcm sunar. <code>@ExceptionHandler<\/code> tek ba\u015f\u0131na \u00e7ok s\u0131n\u0131rl\u0131d\u0131r ve <code>HandlerExceptionResolver<\/code> ise genellikle a\u015f\u0131r\u0131ya ka\u00e7an bir karma\u015f\u0131kl\u0131k sunar.<\/p>\n<h2>\u0130stisna Y\u00f6netiminde En \u0130yi Uygulamalar<\/h2>\n<p>Etkili bir istisna y\u00f6netimi stratejisi, sadece teknik implementasyonlardan ibaret de\u011fildir. Uygulaman\u0131n genel kalitesini art\u0131ran baz\u0131 en iyi uygulamalar da vard\u0131r.<\/p>\n<h3>Anlaml\u0131 Hata Mesajlar\u0131 ve Kodlar\u0131<\/h3>\n<p>*   <strong>Kullan\u0131c\u0131 Dostu Mesajlar:<\/strong> Son kullan\u0131c\u0131lara g\u00f6sterilen hata mesajlar\u0131 teknik jargon i\u00e7ermemeli, anla\u015f\u0131l\u0131r ve eyleme d\u00f6n\u00fc\u015ft\u00fcr\u00fclebilir olmal\u0131d\u0131r. \u00d6rne\u011fin, &#8220;Veritaban\u0131 ba\u011flant\u0131s\u0131 kesildi&#8221; yerine &#8220;\u015eu anda i\u015fleminizi ger\u00e7ekle\u015ftiremiyoruz, l\u00fctfen daha sonra tekrar deneyin.&#8221;<br \/>\n*   <strong>Geli\u015ftirici Dostu Mesajlar:<\/strong> Loglara veya geli\u015ftiriciye d\u00f6nen hata mesajlar\u0131, sorunun k\u00f6k nedenini anlamak i\u00e7in yeterli detay\u0131 i\u00e7ermelidir (\u00f6rn: istisna t\u00fcr\u00fc, f\u0131rlat\u0131ld\u0131\u011f\u0131 yer, ilgili parametreler).<br \/>\n*   <strong>Tutarl\u0131 Hata Kodlar\u0131:<\/strong> RESTful API&#8217;lar i\u00e7in, hata yan\u0131tlar\u0131nda standart HTTP durum kodlar\u0131n\u0131n (400 Bad Request, 401 Unauthorized, 403 Forbidden, 404 Not Found, 409 Conflict, 500 Internal Server Error vb.) yan\u0131 s\u0131ra, uygulaman\u0131za \u00f6zg\u00fc dahili hata kodlar\u0131 da sa\u011flayabilirsiniz. Bu, istemci uygulamalar\u0131n belirli hata durumlar\u0131n\u0131 programatik olarak tan\u0131mas\u0131n\u0131 ve i\u015flemesini sa\u011flar.<br \/>\n*   <strong>JSON API Problem Details:<\/strong> RFC 7807 (Problem Details for HTTP APIs) standard\u0131, API&#8217;lar i\u00e7in tutarl\u0131 ve makine taraf\u0131ndan okunabilir hata yan\u0131tlar\u0131 olu\u015fturmak i\u00e7in harika bir yakla\u015f\u0131md\u0131r. Spring Boot, bu standard\u0131 desteklemek i\u00e7in ara\u00e7lar sunar.<\/p>\n<h3>Loglama<\/h3>\n<p>*   T\u00fcm istisnalar\u0131 uygun log seviyesinde (\u00f6rn: <code>ERROR<\/code> veya <code>WARN<\/code>) loglay\u0131n.<br \/>\n*   <code>ex.printStackTrace()<\/code> yerine bir loglama \u00e7er\u00e7evesi (\u00f6rn: SLF4J\/Logback) kullan\u0131n.<br \/>\n*   Log mesajlar\u0131na, hatan\u0131n ba\u011flam\u0131n\u0131 anlamak i\u00e7in gerekli olabilecek ek bilgileri (kullan\u0131c\u0131 ID&#8217;si, istek URL&#8217;si, parametreler vb.) ekleyin.<br \/>\n*   Y\u0131\u011f\u0131n izlerini (stack traces) loglamak, hatan\u0131n nerede meydana geldi\u011fini h\u0131zl\u0131ca tespit etmek i\u00e7in kritik \u00f6neme sahiptir.<\/p>\n<h3>G\u00fcvenlik<\/h3>\n<p>*   Hata mesajlar\u0131nda veya y\u0131\u011f\u0131n izlerinde hassas bilgileri (veritaban\u0131 kimlik bilgileri, API anahtarlar\u0131, kullan\u0131c\u0131 \u015fifreleri, sunucu yollar\u0131 vb.) asla a\u00e7\u0131\u011fa \u00e7\u0131karmay\u0131n.<br \/>\n*   \u00dcretim ortamlar\u0131nda ayr\u0131nt\u0131l\u0131 hata mesajlar\u0131n\u0131 ve y\u0131\u011f\u0131n izlerini do\u011frudan kullan\u0131c\u0131ya g\u00f6stermeyin. Bunun yerine genel bir hata mesaj\u0131 ve bir referans kodu (bu kodla loglarda hatay\u0131 bulabilirsiniz) g\u00f6sterin.<\/p>\n<h3>Uluslararas\u0131la\u015fma (i18n)<\/h3>\n<p>*   E\u011fer uygulaman\u0131z birden fazla dili destekliyorsa, hata mesajlar\u0131n\u0131z\u0131 da uluslararas\u0131la\u015ft\u0131rman\u0131z gerekir. Spring&#8217;in <code>MessageSource<\/code> aray\u00fcz\u00fc bu konuda size yard\u0131mc\u0131 olabilir.<\/p>\n<h3>Test Edilebilirlik<\/h3>\n<p>*   \u0130stisna senaryolar\u0131n\u0131z\u0131 test etmek, uygulaman\u0131z\u0131n beklenmedik durumlarda do\u011fru \u015fekilde davrand\u0131\u011f\u0131ndan emin olmak i\u00e7in \u00e7ok \u00f6nemlidir.<br \/>\n*   Birim testleri ve entegrasyon testleri ile controller&#8217;lar\u0131n\u0131z\u0131n ve <code>@ControllerAdvice<\/code> s\u0131n\u0131flar\u0131n\u0131z\u0131n farkl\u0131 istisnalar\u0131 do\u011fru \u015fekilde ele ald\u0131\u011f\u0131n\u0131 do\u011frulay\u0131n.<\/p>\n<h2>Sonu\u00e7<\/h2>\n<p>Spring MVC&#8217;de istisna y\u00f6netimi, modern ve sa\u011flam bir web uygulamas\u0131n\u0131n temel bir bile\u015fenidir. <code>@ExceptionHandler<\/code>, <code>@ControllerAdvice<\/code> ve <code>HandlerExceptionResolver<\/code> gibi g\u00fc\u00e7l\u00fc ara\u00e7lar sayesinde Spring, geli\u015ftiricilere istisnalar\u0131 farkl\u0131 seviyelerde ve esnekliklerde ele alma imkan\u0131 sunar.<\/p>\n<p>Makale boyunca, controller seviyesinde <code>@ExceptionHandler<\/code>&#8216;\u0131n basit ama s\u0131n\u0131rl\u0131 kullan\u0131m\u0131ndan, t\u00fcm uygulama genelinde merkezi ve tutarl\u0131 bir \u00e7\u00f6z\u00fcm sunan <code>@ControllerAdvice<\/code> + <code>@ExceptionHandler<\/code> kombinasyonuna ve daha d\u00fc\u015f\u00fck seviyeli, tam kontrol sa\u011flayan <code>HandlerExceptionResolver<\/code> aray\u00fcz\u00fcne kadar \u00e7e\u015fitli yakla\u015f\u0131mlar\u0131 inceledik. \u00c7o\u011fu senaryo i\u00e7in <code>@ControllerAdvice<\/code>&#8216;\u0131n en dengeli ve \u00f6nerilen \u00e7\u00f6z\u00fcm oldu\u011funu vurgulad\u0131k.<\/p>\n<p>Unutulmamal\u0131d\u0131r ki, istisna y\u00f6netimi sadece teknik bir implementasyon meselesi de\u011fil, ayn\u0131 zamanda kullan\u0131c\u0131 deneyimi, g\u00fcvenlik ve uygulama bak\u0131m\u0131 gibi alanlarda da kritik \u00f6neme sahiptir. Anlaml\u0131 hata mesajlar\u0131, do\u011fru loglama, g\u00fcvenlik bilinci ve uluslararas\u0131la\u015fma gibi en iyi uygulamalar\u0131 benimsemek, uygulaman\u0131z\u0131n kalitesini \u00f6nemli \u00f6l\u00e7\u00fcde art\u0131racakt\u0131r. Bu ara\u00e7lar\u0131 ve prensipleri do\u011fru bir \u015fekilde uygulayarak, daha g\u00fcvenilir, kullan\u0131c\u0131 dostu ve s\u00fcrd\u00fcr\u00fclebilir Spring MVC uygulamalar\u0131 geli\u015ftirebilirsiniz.<\/body><\/p>\n","protected":false},"excerpt":{"rendered":"Spring MVC&#8217;de \u0130stisna Y\u00f6netimi: @ControllerAdvice, @ExceptionHandler ve HandlerExceptionResolver\nGiri\u015f\nModern web uygulamalar\u0131, kullan\u0131c\u0131larla","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"csco_page_header_type":"","csco_page_load_nextpost":"","csco_page_subscribe_form":"","csco_page_contact_form":"","footnotes":""},"categories":[1490],"tags":[],"class_list":{"0":"post-30472","1":"post","2":"type-post","3":"status-publish","4":"format-standard","6":"category-mvc","7":"cs-entry","8":"cs-video-wrap"},"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v20.5 (Yoast SEO v25.3.1) - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Spring MVC&#039;de \u0130stisna Y\u00f6netimi: @ControllerAdvice, @ExceptionHandler ve HandlerExceptionResolver - Kodlar\u0131n Gizemli D\u00fcnyas\u0131<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/fatihsoysal.com\/blog\/spring-mvcde-istisna-yonetimi-controlleradvice-exceptionhandler-ve-handlerexceptionresolver\/\" \/>\n<meta property=\"og:locale\" content=\"tr_TR\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Spring MVC&#039;de \u0130stisna Y\u00f6netimi: @ControllerAdvice, @ExceptionHandler ve HandlerExceptionResolver\" \/>\n<meta property=\"og:description\" content=\"Spring MVC&#039;de \u0130stisna Y\u00f6netimi: @ControllerAdvice, @ExceptionHandler ve HandlerExceptionResolver Giri\u015f Modern web uygulamalar\u0131, kullan\u0131c\u0131larla\" \/>\n<meta property=\"og:url\" content=\"https:\/\/fatihsoysal.com\/blog\/spring-mvcde-istisna-yonetimi-controlleradvice-exceptionhandler-ve-handlerexceptionresolver\/\" \/>\n<meta property=\"og:site_name\" content=\"Kodlar\u0131n Gizemli D\u00fcnyas\u0131\" \/>\n<meta property=\"article:published_time\" content=\"2025-09-28T04:40:56+00:00\" \/>\n<meta name=\"author\" content=\"Fatih Soysal\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Yazan:\" \/>\n\t<meta name=\"twitter:data1\" content=\"Fatih Soysal\" \/>\n\t<meta name=\"twitter:label2\" content=\"Tahmini okuma s\u00fcresi\" \/>\n\t<meta name=\"twitter:data2\" content=\"21 dakika\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/fatihsoysal.com\/blog\/spring-mvcde-istisna-yonetimi-controlleradvice-exceptionhandler-ve-handlerexceptionresolver\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/fatihsoysal.com\/blog\/spring-mvcde-istisna-yonetimi-controlleradvice-exceptionhandler-ve-handlerexceptionresolver\/\"},\"author\":{\"name\":\"Fatih Soysal\",\"@id\":\"https:\/\/fatihsoysal.com\/blog\/#\/schema\/person\/002a254750921dcfd568a99e48240dd1\"},\"headline\":\"Spring MVC&#8217;de \u0130stisna Y\u00f6netimi: @ControllerAdvice, @ExceptionHandler ve HandlerExceptionResolver\",\"datePublished\":\"2025-09-28T04:40:56+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/fatihsoysal.com\/blog\/spring-mvcde-istisna-yonetimi-controlleradvice-exceptionhandler-ve-handlerexceptionresolver\/\"},\"wordCount\":3381,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/fatihsoysal.com\/blog\/#\/schema\/person\/002a254750921dcfd568a99e48240dd1\"},\"articleSection\":[\"MVC\"],\"inLanguage\":\"tr\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/fatihsoysal.com\/blog\/spring-mvcde-istisna-yonetimi-controlleradvice-exceptionhandler-ve-handlerexceptionresolver\/#respond\"]}],\"copyrightYear\":\"2025\",\"copyrightHolder\":{\"@id\":\"https:\/\/fatihsoysal.com\/blog\/#organization\"}},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/fatihsoysal.com\/blog\/spring-mvcde-istisna-yonetimi-controlleradvice-exceptionhandler-ve-handlerexceptionresolver\/\",\"url\":\"https:\/\/fatihsoysal.com\/blog\/spring-mvcde-istisna-yonetimi-controlleradvice-exceptionhandler-ve-handlerexceptionresolver\/\",\"name\":\"Spring MVC'de \u0130stisna Y\u00f6netimi: @ControllerAdvice, @ExceptionHandler ve HandlerExceptionResolver - Kodlar\u0131n Gizemli D\u00fcnyas\u0131\",\"isPartOf\":{\"@id\":\"https:\/\/fatihsoysal.com\/blog\/#website\"},\"datePublished\":\"2025-09-28T04:40:56+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/fatihsoysal.com\/blog\/spring-mvcde-istisna-yonetimi-controlleradvice-exceptionhandler-ve-handlerexceptionresolver\/#breadcrumb\"},\"inLanguage\":\"tr\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/fatihsoysal.com\/blog\/spring-mvcde-istisna-yonetimi-controlleradvice-exceptionhandler-ve-handlerexceptionresolver\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/fatihsoysal.com\/blog\/spring-mvcde-istisna-yonetimi-controlleradvice-exceptionhandler-ve-handlerexceptionresolver\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Anasayfa\",\"item\":\"https:\/\/fatihsoysal.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Spring MVC&#8217;de \u0130stisna Y\u00f6netimi: @ControllerAdvice, @ExceptionHandler ve HandlerExceptionResolver\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/fatihsoysal.com\/blog\/#website\",\"url\":\"https:\/\/fatihsoysal.com\/blog\/\",\"name\":\"Fatihsoysal.com\",\"description\":\"Blog - Yaz\u0131l\u0131m D\u00fcnyas\u0131 Tecr\u00fcbelerim\",\"publisher\":{\"@id\":\"https:\/\/fatihsoysal.com\/blog\/#\/schema\/person\/002a254750921dcfd568a99e48240dd1\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/fatihsoysal.com\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"tr\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\/\/fatihsoysal.com\/blog\/#\/schema\/person\/002a254750921dcfd568a99e48240dd1\",\"name\":\"Fatih Soysal\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"tr\",\"@id\":\"https:\/\/fatihsoysal.com\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/fatihsoysal.com\/blog\/wp-content\/uploads\/2024\/04\/cropped-replicate-prediction-3kgg1hgjn5rgp0cf0p5tr0jw7w-1.png\",\"contentUrl\":\"https:\/\/fatihsoysal.com\/blog\/wp-content\/uploads\/2024\/04\/cropped-replicate-prediction-3kgg1hgjn5rgp0cf0p5tr0jw7w-1.png\",\"width\":512,\"height\":512,\"caption\":\"Fatih Soysal\"},\"logo\":{\"@id\":\"https:\/\/fatihsoysal.com\/blog\/#\/schema\/person\/image\/\"},\"description\":\"Kullan\u0131m ve kodlama m\u00fckemmeliyetini odak alan uygulamalar olu\u015fturma deneyimine sahip, profesyonel olarak 15+ y\u0131l \u00fczeri deneyime sahip bir yaz\u0131l\u0131m m\u00fchendisi.\",\"url\":\"https:\/\/fatihsoysal.com\/blog\/author\/fatihsoysal\/\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"Spring MVC'de \u0130stisna Y\u00f6netimi: @ControllerAdvice, @ExceptionHandler ve HandlerExceptionResolver - Kodlar\u0131n Gizemli D\u00fcnyas\u0131","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/fatihsoysal.com\/blog\/spring-mvcde-istisna-yonetimi-controlleradvice-exceptionhandler-ve-handlerexceptionresolver\/","og_locale":"tr_TR","og_type":"article","og_title":"Spring MVC'de \u0130stisna Y\u00f6netimi: @ControllerAdvice, @ExceptionHandler ve HandlerExceptionResolver","og_description":"Spring MVC'de \u0130stisna Y\u00f6netimi: @ControllerAdvice, @ExceptionHandler ve HandlerExceptionResolver Giri\u015f Modern web uygulamalar\u0131, kullan\u0131c\u0131larla","og_url":"https:\/\/fatihsoysal.com\/blog\/spring-mvcde-istisna-yonetimi-controlleradvice-exceptionhandler-ve-handlerexceptionresolver\/","og_site_name":"Kodlar\u0131n Gizemli D\u00fcnyas\u0131","article_published_time":"2025-09-28T04:40:56+00:00","author":"Fatih Soysal","twitter_card":"summary_large_image","twitter_misc":{"Yazan:":"Fatih Soysal","Tahmini okuma s\u00fcresi":"21 dakika"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/fatihsoysal.com\/blog\/spring-mvcde-istisna-yonetimi-controlleradvice-exceptionhandler-ve-handlerexceptionresolver\/#article","isPartOf":{"@id":"https:\/\/fatihsoysal.com\/blog\/spring-mvcde-istisna-yonetimi-controlleradvice-exceptionhandler-ve-handlerexceptionresolver\/"},"author":{"name":"Fatih Soysal","@id":"https:\/\/fatihsoysal.com\/blog\/#\/schema\/person\/002a254750921dcfd568a99e48240dd1"},"headline":"Spring MVC&#8217;de \u0130stisna Y\u00f6netimi: @ControllerAdvice, @ExceptionHandler ve HandlerExceptionResolver","datePublished":"2025-09-28T04:40:56+00:00","mainEntityOfPage":{"@id":"https:\/\/fatihsoysal.com\/blog\/spring-mvcde-istisna-yonetimi-controlleradvice-exceptionhandler-ve-handlerexceptionresolver\/"},"wordCount":3381,"commentCount":0,"publisher":{"@id":"https:\/\/fatihsoysal.com\/blog\/#\/schema\/person\/002a254750921dcfd568a99e48240dd1"},"articleSection":["MVC"],"inLanguage":"tr","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/fatihsoysal.com\/blog\/spring-mvcde-istisna-yonetimi-controlleradvice-exceptionhandler-ve-handlerexceptionresolver\/#respond"]}],"copyrightYear":"2025","copyrightHolder":{"@id":"https:\/\/fatihsoysal.com\/blog\/#organization"}},{"@type":"WebPage","@id":"https:\/\/fatihsoysal.com\/blog\/spring-mvcde-istisna-yonetimi-controlleradvice-exceptionhandler-ve-handlerexceptionresolver\/","url":"https:\/\/fatihsoysal.com\/blog\/spring-mvcde-istisna-yonetimi-controlleradvice-exceptionhandler-ve-handlerexceptionresolver\/","name":"Spring MVC'de \u0130stisna Y\u00f6netimi: @ControllerAdvice, @ExceptionHandler ve HandlerExceptionResolver - Kodlar\u0131n Gizemli D\u00fcnyas\u0131","isPartOf":{"@id":"https:\/\/fatihsoysal.com\/blog\/#website"},"datePublished":"2025-09-28T04:40:56+00:00","breadcrumb":{"@id":"https:\/\/fatihsoysal.com\/blog\/spring-mvcde-istisna-yonetimi-controlleradvice-exceptionhandler-ve-handlerexceptionresolver\/#breadcrumb"},"inLanguage":"tr","potentialAction":[{"@type":"ReadAction","target":["https:\/\/fatihsoysal.com\/blog\/spring-mvcde-istisna-yonetimi-controlleradvice-exceptionhandler-ve-handlerexceptionresolver\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/fatihsoysal.com\/blog\/spring-mvcde-istisna-yonetimi-controlleradvice-exceptionhandler-ve-handlerexceptionresolver\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Anasayfa","item":"https:\/\/fatihsoysal.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Spring MVC&#8217;de \u0130stisna Y\u00f6netimi: @ControllerAdvice, @ExceptionHandler ve HandlerExceptionResolver"}]},{"@type":"WebSite","@id":"https:\/\/fatihsoysal.com\/blog\/#website","url":"https:\/\/fatihsoysal.com\/blog\/","name":"Fatihsoysal.com","description":"Blog - Yaz\u0131l\u0131m D\u00fcnyas\u0131 Tecr\u00fcbelerim","publisher":{"@id":"https:\/\/fatihsoysal.com\/blog\/#\/schema\/person\/002a254750921dcfd568a99e48240dd1"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/fatihsoysal.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"tr"},{"@type":["Person","Organization"],"@id":"https:\/\/fatihsoysal.com\/blog\/#\/schema\/person\/002a254750921dcfd568a99e48240dd1","name":"Fatih Soysal","image":{"@type":"ImageObject","inLanguage":"tr","@id":"https:\/\/fatihsoysal.com\/blog\/#\/schema\/person\/image\/","url":"https:\/\/fatihsoysal.com\/blog\/wp-content\/uploads\/2024\/04\/cropped-replicate-prediction-3kgg1hgjn5rgp0cf0p5tr0jw7w-1.png","contentUrl":"https:\/\/fatihsoysal.com\/blog\/wp-content\/uploads\/2024\/04\/cropped-replicate-prediction-3kgg1hgjn5rgp0cf0p5tr0jw7w-1.png","width":512,"height":512,"caption":"Fatih Soysal"},"logo":{"@id":"https:\/\/fatihsoysal.com\/blog\/#\/schema\/person\/image\/"},"description":"Kullan\u0131m ve kodlama m\u00fckemmeliyetini odak alan uygulamalar olu\u015fturma deneyimine sahip, profesyonel olarak 15+ y\u0131l \u00fczeri deneyime sahip bir yaz\u0131l\u0131m m\u00fchendisi.","url":"https:\/\/fatihsoysal.com\/blog\/author\/fatihsoysal\/"}]}},"yoast_meta":{"yoast_wpseo_title":"","yoast_wpseo_metadesc":"","yoast_wpseo_canonical":""},"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/fatihsoysal.com\/blog\/wp-json\/wp\/v2\/posts\/30472","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fatihsoysal.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fatihsoysal.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fatihsoysal.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fatihsoysal.com\/blog\/wp-json\/wp\/v2\/comments?post=30472"}],"version-history":[{"count":1,"href":"https:\/\/fatihsoysal.com\/blog\/wp-json\/wp\/v2\/posts\/30472\/revisions"}],"predecessor-version":[{"id":30473,"href":"https:\/\/fatihsoysal.com\/blog\/wp-json\/wp\/v2\/posts\/30472\/revisions\/30473"}],"wp:attachment":[{"href":"https:\/\/fatihsoysal.com\/blog\/wp-json\/wp\/v2\/media?parent=30472"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fatihsoysal.com\/blog\/wp-json\/wp\/v2\/categories?post=30472"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fatihsoysal.com\/blog\/wp-json\/wp\/v2\/tags?post=30472"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}