@@ -82,10 +82,12 @@ internal class NumericBoundParser(
8282 internal fun parse (bound : String , exclusive : Boolean ): KNumericBound {
8383 with (metadata) {
8484 Compilation .check(bound.isNotEmpty(), file, field.span) {
85- " The `($optionName )` option could not parse the bound value specified for" +
86- " `${field.qualifiedName} ` field because it is empty. Please provide" +
87- " either a numeric value or refer to a value of another field via" +
88- " its name or a path, if the field is nested."
85+ """
86+ The `($optionName )` option could not parse the passed bound value.
87+ Target field: `${field.qualifiedName} `.
88+ Reason: the passed value is empty.
89+ Please provide either a numeric value or refer to a value of another field via its name or a path, if the field is nested.
90+ """ .trimIndent()
8991 }
9092 }
9193 return if (bound.isFieldReference()) {
@@ -101,15 +103,25 @@ internal class NumericBoundParser(
101103 ): KNumericBound {
102104 if (fieldType in listOf (TYPE_FLOAT , TYPE_DOUBLE )) {
103105 Compilation .check(FLOAT .matches(number), file, field.span) {
104- " The `($optionName )` option could not parse the `$number ` bound value specified" +
105- " for `${field.qualifiedName} ` field. Please make sure the provided value" +
106- " is a floating-point number. Examples: `12.3`, `-0.1`, `6.02E2`."
106+ """
107+ The `($optionName )` option could not parse the passed bound value.
108+ The passed value: `$number `.
109+ Target field: `${field.qualifiedName} `.
110+ Field type: `${field.type.name} `.
111+ Reason: a floating-point number is expected for floating-point fields.
112+ Examples: `12.3`, `-0.1`, `6.02E2`.
113+ """ .trimIndent()
107114 }
108115 } else {
109116 Compilation .check(INTEGER .matches(number), file, field.span) {
110- " The `($optionName )` option could not parse the `$number ` bound value specified" +
111- " for `${field.qualifiedName} ` field. Please make sure the provided value" +
112- " is an integer number. Examples: `123`, `-567823`."
117+ """
118+ The `($optionName )` option could not parse the passed bound value.
119+ The passed value: `$number `.
120+ Target field: `${field.qualifiedName} `.
121+ Field type: `${field.type.name} `.
122+ Reason: an integer number is expected for integer fields.
123+ Examples: `123`, `-567823`.
124+ """ .trimIndent()
113125 }
114126 }
115127
@@ -124,9 +136,13 @@ internal class NumericBoundParser(
124136 }
125137
126138 Compilation .check(parsed != null , file, field.span) {
127- " The `($optionName )` option could not parse the `$number ` bound value specified for" +
128- " `${field.qualifiedName} ` field. The value is out of range for the field" +
129- " type `${field.type.name} ` the option is applied to."
139+ """
140+ The `($optionName )` option could not parse the passed bound value.
141+ The passed value: `$number `.
142+ Target field: `${field.qualifiedName} `.
143+ Field type: `${field.type.name} `.
144+ Reason: the value is out of range for the field type.
145+ """ .trimIndent()
130146 }
131147
132148 return KNumericBound (parsed!! , exclusive)
@@ -137,9 +153,13 @@ internal class NumericBoundParser(
137153 exclusive : Boolean
138154 ): KNumericBound {
139155 Compilation .check(fieldPath != field.name.value, file, field.span) {
140- " The `($optionName )` option cannot use `$fieldPath ` field as a bound value for" +
141- " the `${field.qualifiedName} ` because self-referencing is prohibited." +
142- " Please use other message fields."
156+ """
157+ The `($optionName )` option cannot use the specified field value as a bound.
158+ The specified field: `$fieldPath `.
159+ Target field: `${field.qualifiedName} `.
160+ Reason: self-referencing is prohibited.
161+ Please refer to a value of another field via its name or a path, if the field is nested.
162+ """ .trimIndent()
143163 }
144164
145165 val boundFieldPath = io.spine.base.fieldPath {
@@ -151,17 +171,26 @@ internal class NumericBoundParser(
151171 typeSystem.resolve(boundFieldPath, messageType)
152172 } catch (e: IllegalStateException ) {
153173 Compilation .error(file, field.span) {
154- " The `($optionName )` option could not parse the `$fieldPath ` field path specified" +
155- " for `${field.qualifiedName} ` field. Please make sure the provided field" +
156- " path is valid: `${e.message} `."
174+ """
175+ The `($optionName )` option could not parse the specified field path.
176+ The specified field path: `$fieldPath `.
177+ Target field: `${field.qualifiedName} `.
178+ Reason: the specified field does not exist, or one of the components of the field path represents a non-message field.
179+ Please make sure the provided field path references an existing field.
180+ """ .trimIndent()
157181 }
158182 }
159183
160184 val boundFieldType = boundField.type.primitive
161185 Compilation .check(boundFieldType in numericPrimitives, file, field.span) {
162- " The `($optionName )` option cannot use `$fieldPath ` field as a bound value for" +
163- " the `${field.qualifiedName} ` field due to its type" +
164- " `${boundFieldType.name} `. Only singular numeric fields are supported."
186+ """
187+ The `($optionName )` option cannot use the specified field as a bound value.
188+ The specified field: `$fieldPath `.
189+ Type of the specified field: `${boundFieldType.name} `.
190+ Target field: `${field.qualifiedName} `.
191+ Reason: the specified field is not of numeric type.
192+ Please specify a field of singular numeric type.
193+ """ .trimIndent()
165194 }
166195
167196 return KNumericBound (boundFieldPath, exclusive)
0 commit comments