22
33import module java .base ;
44
5- import com .fasterxml .jackson .core .JsonProcessingException ;
65import com .fasterxml .jackson .databind .ObjectMapper ;
76import io .swagger .v3 .oas .annotations .Operation ;
87import io .swagger .v3 .oas .annotations .responses .ApiResponse ;
98import io .swagger .v3 .oas .annotations .responses .ApiResponses ;
109import net .ironoc .portfolio .graph .BrewsResolver ;
1110import net .ironoc .portfolio .service .GraphQLClient ;
11+ import net .ironoc .portfolio .exception .IronocJsonException ;
1212import net .ironoc .portfolio .logger .AbstractLogger ;
1313import net .ironoc .portfolio .domain .CoffeeDomain ;
1414import net .ironoc .portfolio .service .Coffees ;
@@ -104,8 +104,12 @@ public ResponseEntity<List<CoffeeDomain>> getCoffeeDetailsGraphQl() {
104104 try {
105105 CoffeeDomain coffeeDomain = new ObjectMapper ().convertValue (coffeeMap , CoffeeDomain .class );
106106 coffeeDomains .add (coffeeDomain );
107- } catch (Exception e ) {
108- error ("Error occurred mapping coffee domain object" , e .getMessage ());
107+ } catch (IllegalArgumentException e ) {
108+ error ("Error occurred mapping coffee domain object" , e );
109+ throw new IronocJsonException (
110+ "Failed to map GraphQL coffee payload: " + e .getMessage (),
111+ e
112+ );
109113 }
110114 }
111115
@@ -114,10 +118,12 @@ public ResponseEntity<List<CoffeeDomain>> getCoffeeDetailsGraphQl() {
114118 coffeesCache .put (coffeeDomains );
115119
116120 return ResponseEntity .ok (coffeeDomains );
117- } catch (JsonProcessingException e ) {
121+ } catch (IronocJsonException e ) {
122+ throw e ;
123+ } catch (Exception e ) {
118124 error ("Unexpected exception occurred loading GraphQL query, msg={}" , e .getMessage ());
125+ throw new IronocJsonException ("Unexpected exception occurred loading GraphQL query" , e );
119126 }
120- return ResponseEntity .ok (Collections .emptyList ());
121127 } else {
122128 debug ("Returning cached brews, cachedResults={}" , cachedResults );
123129 return ResponseEntity .ok (cachedResults );
0 commit comments