You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@daffodil.apache.org by "Steve Lawrence (Jira)" <ji...@apache.org> on 2021/07/09 17:11:00 UTC

[jira] [Updated] (DAFFODIL-2542) Change diagnostics to use string interpolation

     [ https://issues.apache.org/jira/browse/DAFFODIL-2542?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Steve Lawrence updated DAFFODIL-2542:
-------------------------------------
    Issue Type: Improvement  (was: Bug)

> Change diagnostics to use string interpolation
> ----------------------------------------------
>
>                 Key: DAFFODIL-2542
>                 URL: https://issues.apache.org/jira/browse/DAFFODIL-2542
>             Project: Daffodil
>          Issue Type: Improvement
>          Components: Diagnostics
>            Reporter: Steve Lawrence
>            Priority: Minor
>              Labels: beginner
>
> Our various diagnostics use a format string plus varargs to build a message. For example
> {code:scala}
> this.SDE("Some error message: %s", someArgument)
> {code}
> One downside of this approach is that there is no compile time validation of the format string and arguments. So if the the format strings and args don't match, it can lead to unexpected error messages or runtime errors.
> An alternative approach is to use string interpolation:
> {code:scala}
> this.SDE(s"Some error message: ${someArgument}")
> {code}
> This completely avoids the possibility of format string/var args missmatch.
> We should go through our diagnostic messages and switch to using string interpolation.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)