andersnm / ExcelNumberFormat

Parse and render Excel number format strings
MIT License
79 stars 27 forks source link

Throw exception when invalid format is used. #4

Closed igitur closed 6 years ago

igitur commented 6 years ago

I think it's better to throw a library-specific exception when an invalid format is used, instead of returning a hardcoded string. It should be up to the user to treat the exception.

andersnm commented 6 years ago

Have reorganized a bit to make the Formatter class simpler and lower level so this might not be needed.

Assuming the files are copied into another project, the NumberFormat class' error handling could be adapted to project specific needs, as it's essentially a thin wrapper over the underlying Parser and Formatter classes. In case of errors the default implementation falls back to using Convert.ToString().

Closing this for now. I'm thinking perhaps the low level Formatter.Format() method should throw FormatException consistently instead.