@@ -250,7 +250,10 @@ private static String getterExpr(
250250 // field is accessible with a getter
251251 final Method getter =
252252 getStructuredFieldGetter (implementationClass , field )
253- .orElseThrow (IllegalStateException ::new );
253+ .orElseThrow (
254+ () ->
255+ fieldNotReadableException (
256+ implementationClass , fieldName ));
254257 accessExpr = expr ("external." , getter .getName (), "()" );
255258 }
256259 accessExpr = castExpr (accessExpr , fieldClass );
@@ -264,6 +267,25 @@ private static String getterExpr(
264267 "))" );
265268 }
266269
270+ private static IllegalStateException fieldNotReadableException (
271+ Class <?> implementationClass , String fieldName ) {
272+ return new IllegalStateException (
273+ String .format (
274+ "Could not find a getter for field '%s' in class '%s'. "
275+ + "Make sure that the field is readable (via public visibility or getter)." ,
276+ fieldName , implementationClass .getName ()));
277+ }
278+
279+ private static IllegalStateException fieldNotWritableException (
280+ Class <?> implementationClass , String fieldName ) {
281+ return new IllegalStateException (
282+ String .format (
283+ "Could not find a setter for field '%s' in class '%s'. "
284+ + "Make sure that the field is writable (via public visibility, "
285+ + "setter, or full constructor)." ,
286+ fieldName , implementationClass .getName ()));
287+ }
288+
267289 private static String parameterExpr (int pos , Class <?> fieldClass ) {
268290 final String conversionExpr =
269291 expr (
@@ -295,7 +317,10 @@ private static String setterExpr(Class<?> implementationClass, int pos, String f
295317 // field is accessible with a setter
296318 final Method setter =
297319 getStructuredFieldSetter (implementationClass , field )
298- .orElseThrow (IllegalStateException ::new );
320+ .orElseThrow (
321+ () ->
322+ fieldNotWritableException (
323+ implementationClass , fieldName ));
299324 return expr (
300325 "structured." ,
301326 setter .getName (),
0 commit comments