Java-Gaming.org Hi !
Featured games (91)
games approved by the League of Dukes
Games in Showcase (799)
Games in Android Showcase (235)
games submitted by our members
Games in WIP (865)
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 2809 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: 746



« 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  
 
 

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

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

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

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

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

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

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

EgonOlsen (2902 views)
2018-06-10 19:43:20

DesertCoockie (3826 views)
2018-05-13 18:23:11

nelsongames (4200 views)
2018-04-24 18:15:36
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

Deployment and Packaging
by gouessej
2018-08-22 08:03:45
java-gaming.org 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‑gaming.org
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!