Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Obscure error message in the formatting API #471

Open
dkhalanskyjb opened this issue Jan 8, 2025 · 0 comments · May be fixed by #472
Open

Obscure error message in the formatting API #471

dkhalanskyjb opened this issue Jan 8, 2025 · 0 comments · May be fixed by #472
Assignees
Labels
bug Something isn't working formatters Related to parsing and formatting

Comments

@dkhalanskyjb
Copy link
Collaborator

Reported to us in private.

    private val readableFormat = DateTimeComponents.Format {
        year()
        char('-')
        monthNumber()
        char('-')
        dayOfMonth()
        char(' ')
        hour()
        char(':')
        minute()
        char(':')
        second()
        alternativeParsing({}) {
            char(' ')
        }
        alternativeParsing(
            { timeZoneId() },
            { offset(UtcOffset.Formats.ISO) }
        ) {
            offsetHours()
            char(':')
            offsetMinutesOfHour()
            optional {
                char(':')
                offsetSecondsOfMinute()
            }
        }
    }

    public fun format(value: Instant): String {
        return readableFormat.format {
            setDateTime(value.toLocalDateTime(zone))
            timeZoneId = zone.id
        }
    }

The error message is unreadable:

java.lang.IllegalStateException: Field totalHoursAbs is not set
@dkhalanskyjb dkhalanskyjb added bug Something isn't working formatters Related to parsing and formatting labels Jan 8, 2025
@dkhalanskyjb dkhalanskyjb self-assigned this Jan 8, 2025
@dkhalanskyjb dkhalanskyjb changed the title Obscure error message in the parsing API Obscure error message in the formatting API Jan 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working formatters Related to parsing and formatting
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant