Skip to content

Obscure error message in the formatting API #471

Open
@dkhalanskyjb

Description

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

Metadata

Assignees

Labels

bugSomething isn't workingformattersRelated to parsing and formatting

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions