Git Product home page Git Product logo

Comments (5)

JesusMcCloud avatar JesusMcCloud commented on August 12, 2024

The issue raised by @jsiwrk needs addressing, however error messages are probably the wrong way to go about this because:

  1. Messages can change
  2. Messages are comprehensible by humans, but hard to parse
  3. Error messages my be incosistent without anyone really noticing it, as long as the stack traces are also interpreted (by a human) for additional context
  4. i18n

It is tempting tempting to simply move error messages into a ResourceBundle and be done with it, since this would solve all of these issues.
Personally, I'm a bit hesitant on this, as I am not sure whether I'm overlooking something.
I therefore welcome any input on this discussion!

from hcert-kotlin.

jsiwrk avatar jsiwrk commented on August 12, 2024

Initially I was thinking about returning a simple (and non-internationalized) error message, but as you say, it's true that this would limit the possible use cases of this feature (message recorded in application logs and interpreted by a human expert).

One option would be to introduce a secondary error code (similarly to the secondary status code of SAML). This (optional) secondary error code would refine the primary code when appropriate; e.g. to clarify the reason for CWT_EXPIRED.

Another option would be of course to augment the set of primary codes to render the secondary code unnecessary. (But this could not be appropriate if many additional codes were needed, or if a reduced/concise set of codes is required for interoperability/standardization reasons... I guess.)

A secondary code cannot convey as much information as an error message (e.g. the actual date that has been detected as expired), but this could not be necessary for the intended use case of this feature (deterministic processing by an application or non-expert human).

And there is also the option of returning both: a secondary error code for deterministic processing, and an internal error message for advanced diagnostics (that the application would typically log as is; no internationalization would be required). One could argue though that the internal logs of the library are sufficient for the latter purpose; but on the other hand, the application/service could prefer to handle the logging by itself.

To summarize: no idea of what's the best option either. ;-)

from hcert-kotlin.

JesusMcCloud avatar JesusMcCloud commented on August 12, 2024

Thanks for following up!
I did not think about contextual information such as the exact expiration date causing the expiry.

I still maintain that some "fixed" set of error codes/messages/… is the way to go, as it would have the nice side effect of all potential errors being enumerable.
When combining this with contextual information, using sealed classes for errors come to mind, as it would allow for adding additional information as desired and still implement an error handler fully capable of dealing with all bit of information ever produced.

from hcert-kotlin.

jsiwrk avatar jsiwrk commented on August 12, 2024

Proposed another simple alternative in PR #46, just to see how it looks. It's untyped and surely not as elegant as using sealed error classes, but maybe simpler is best in this case (?). Anyway, feel free to discard this PR without further explanation if you don't like it.

from hcert-kotlin.

JesusMcCloud avatar JesusMcCloud commented on August 12, 2024

GH-46 merged, thanks! I'll leave this open for now, since there are still some error cases, which do not utilise this new feature.

from hcert-kotlin.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.