Hi !
Featured games (91)
games approved by the League of Dukes
Games in Showcase (808)
Games in Android Showcase (239)
games submitted by our members
Games in WIP (872)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Handling end-the-program situations in LWJGL  (Read 5123 times)
0 Members and 1 Guest are viewing this topic.
Offline DesertCookie

Senior Newbie

Exp: 5 years

« Posted 2019-07-08 07:45:57 »

I have seen many ways of handling program critical errors in LWJGL. Such a situation would be the GLFW window handle of glfwCreateWindow being zero, for example, because width or height are <=0.
Personally, I've always thrown exceptions at this point. I've also seen System.exit coupled with an error message. Recently someone suggested assertions to me.

What is the most conventional and useful way, in your opinion?
Offline KaiHH

JGO Kernel

Medals: 820

« Reply #1 - Posted 2019-07-08 08:49:40 »

I'd say it depends. In a development environment you certainly want to fail fast and with the most possible information you can get. So definitely throw an exception with a meaningful stack trace and with debug line numbers enabled during compilation.
When deploying to a customer/client, you probably don't want them to see a Java stack trace, even though that might be helpful for you to diagnose the problem. You'd then have the exception and all other related information stored in a file and maybe provide the user with the ability to upload the diagnostics file to you (your server) also with the option to view every submitted information before sending them.
I certainly would not call System.exit() anywhere in your code.
Offline nsigma
« Reply #2 - Posted 2019-07-09 09:25:50 »

Recently someone suggested assertions to me.

Assertions are only useful for you during development though.  I assume you / they are not shipping things to end users with assertions enabled!  Shocked

Praxis LIVE - hybrid visual IDE for (live) creative coding
Pages: [1]
  ignore  |  Print  

mercenarius (9 views)
2020-06-04 19:26:01

mercenarius (13 views)
2020-06-04 19:13:43

Riven (853 views)
2019-09-04 15:33:17

hadezbladez (5839 views)
2018-11-16 13:46:03

hadezbladez (2648 views)
2018-11-16 13:41:33

hadezbladez (6264 views)
2018-11-16 13:35:35

hadezbladez (1506 views)
2018-11-16 13:32:03

EgonOlsen (4742 views)
2018-06-10 19:43:48

EgonOlsen (5801 views)
2018-06-10 19:43:44

EgonOlsen (3292 views)
2018-06-10 19:43:20
A NON-ideal modular configuration for Eclipse with JavaFX
by philfrei
2019-12-19 19:35:12

Java Gaming Resources
by philfrei
2019-05-14 16:15:13

Deployment and Packaging
by philfrei
2019-05-08 15:15:36

Deployment and Packaging
by philfrei
2019-05-08 15:13:34

Deployment and Packaging
by philfrei
2019-02-17 20:25:53

Deployment and Packaging
by mudlee
2018-08-22 18:09:50

Java Gaming Resources
by gouessej
2018-08-22 08:19:41

Deployment and Packaging
by gouessej
2018-08-22 08:04:08 is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!