ByteCode.News
Submit RSS Atom Sign in

Back to the channels

#java

  1. jreicher javabot: welcome back
  2. javabot jreicher, what does that even *mean*?
  3. jreicher Only that I missed you. Never mind.
  4. jreicher Heh. cheeser the log of the above has the wrong nick for the bot. :)
  5. enoq let's say you have some values in your configs that you need to set and they're absent due to a mistake, do you throw a custom exception here or reach for something like IllegalStateException?
  6. enoq there's nothing to recover from really
  7. Inline yah, let the user know the state is not ok
  8. Inline not because of something wrong but rather something missing/absent
  9. enoq so no RequiredConfigValueMissingException
  10. Inline yah
  11. enoq I mean you can always explain the issue in the message
  12. Inline that exception by name already tells much
  13. Inline I don't think you want to spout more than required polluting the vision of the user etc.
  14. enoq not sure if this is sarcasm or enlightenment
  15. Inline fail early, fail hard, fail loudly
  16. Inline hmmmm
  17. Inline there's no rule fail verbosely
  18. enoq at least my gutt feeling is that introducing custom exceptions makes sense if they could be caught
  19. Inline right
  20. Inline if it's domain specific anyway....
  21. Inline catch what you can
  22. Inline and handle it if you can, otherwise err as generic
  23. Bombe Sometimes I do both: class RequiredValueMissing extends IllegateStateException {}.
  24. deebo anyone aware of some sort of "remote data repository" for spring data repositories over spring-data-rest ? just to avoid writing the client as well
  25. dreamreal ~gpt anyone know of a spring client library for REST semantics, sort of a "remote data repository"?
  26. javabot Yes, there is one such library called Spring RestTemplate. It's a synchronous HTTP client for making HTTP requests to consume RESTful web services. However, RestTemplate is in maintenance mode and the Spring team suggests using WebClient from the Spring WebFlux project for new projects. You can find more about WebClient here: https://docs.spring.io/spring-framework/docs/5.0.0.BUILD-SNAPSHOT/javadoc-api/org/springframework/web/reactive/function/client/Web
  27. dreamreal DO NOT PAY ATTENTION TO THE LLM.
  28. dreamreal The problem is that it's not a "repository" - it's a rest call, and there's not a direct equivalent for repository semantics. RestTemplate > WebFlux, anyway.
  29. dreamreal You could get closer with graphql, but only for read semantics.
  30. Para jdbc-over-http sounds like something people used to do back in the IT bubble days
  31. dreamreal they didn't, though: it sounds like something that would have been tried, but getting connections over RMI was never allowed :D
  32. jreicher enoq: did you read the JDK definition of IllegalStateException? I don't think it's for what you have in mind. Also, why do you want to throw an exception at all? Does it help your code somehow?
  33. enoq jreicher, thank you, sounds like I need something else; as for the exception itself: yes, I can't proceed with the script invocation without the target API configs so exiting with an error seems fine
  34. jreicher Hmm. How are you loading the configs? If you're using a library of some kind it'll probably have exceptions already.
  35. dreamreal Why not throw RuntimeException or a derivative of it
  36. enoq jreicher, no library; I know there things like Spring provide an easy way to map that onto POJOs but it's a very simple script
  37. enoq dreamreal, that'd be the obvious case for defining a custom exception; just wondering if it's worth the ceremony and if there's something built in that works for these cases
  38. enoq could also through a generic RuntimeException("message here") I guess
  39. dreamreal I'd say build the custom exception, personally; if that's "ceremony" your metric for ceremony's set very oddly to me
  40. dreamreal inodes are CHEAP
  41. enoq thanks
  42. jreicher enoq: in my opinion, since you're not using a standard library, and since it sounds like your program can't proceed with a malformed config, this boils down to the nicest way for your code to terminate. You could always call exit(), but allowing main to throw an exception might be nicer.
  43. jreicher What you might like to consider doing is writing the presence of the config as an assert, and then enabling the assertion mechanism. The rest will be taken care of for you.
  44. jreicher As I said, it feels like a coding style question.
  45. enoq thank you