Fractal Softworks Forum

Please login or register.

Login with username, password and session length

Author Topic: "LazyLib Required" User Friendly Error Messages  (Read 3248 times)

Sundog

  • Admiral
  • *****
  • Posts: 1727
    • View Profile
"LazyLib Required" User Friendly Error Messages
« on: November 09, 2014, 06:46:09 PM »

What do you folks think of this? It could just as easily be applied to ShaderLib or other dependencies. (Edit: It might be applicable to other dependencies as well)



Code
public class MyModPlugin extends BaseModPlugin {
    
    @Override
    public void onApplicationLoad() throws ClassNotFoundException {
        try {
            Global.getSettings().getScriptClassLoader().loadClass("org.lazywizard.lazylib.ModUtils");
        } catch (ClassNotFoundException ex) {
            String message = System.lineSeparator() + System.lineSeparator()
                    + "LazyLib is required to run at least one of the mods you have installed."
                    + System.lineSeparator() + System.lineSeparator()
                    + "You can download LazyLib at http://fractalsoftworks.com/forum/index.php?topic=5444"
                    + System.lineSeparator();
            throw new ClassNotFoundException(message);
        }
    }

...

Also, there's got to be a better way than using  +System.lineSeparator()...
« Last Edit: November 10, 2014, 08:06:19 AM by Sundog »
Logged

Dark.Revenant

  • Admiral
  • *****
  • Posts: 2806
    • View Profile
    • Sc2Mafia
Re: "LazyLib Required" User Friendly Error Messages
« Reply #1 on: November 09, 2014, 06:50:50 PM »

If it uses HTML you would just use <br>, right?
Logged

Debido

  • Admiral
  • *****
  • Posts: 1183
    • View Profile
Re: "LazyLib Required" User Friendly Error Messages
« Reply #2 on: November 09, 2014, 07:14:15 PM »

(Copies and pastes code)

Great work, this should stop a few support requests
Logged

Dark.Revenant

  • Admiral
  • *****
  • Posts: 2806
    • View Profile
    • Sc2Mafia
Re: "LazyLib Required" User Friendly Error Messages
« Reply #3 on: November 10, 2014, 01:10:13 AM »

I see, the HTML got messed up on your post.

Also, this is pretty much useless for ShaderLib because if you disable ShaderLib the game will crash before onApplicationLoad() runs.  There's not much I can do about this, unfortunately.
« Last Edit: November 10, 2014, 02:41:40 AM by Dark.Revenant »
Logged

Sundog

  • Admiral
  • *****
  • Posts: 1727
    • View Profile
Re: "LazyLib Required" User Friendly Error Messages
« Reply #4 on: November 10, 2014, 07:58:28 AM »

Also, this is pretty much useless for ShaderLib because if you disable ShaderLib the game will crash before onApplicationLoad() runs.
Oh, that's a shame  :-\

Yeah, there wasn't supposed to be any html in my post at all. The <a href=... > was automatically added at some point without my noticing*. I'll edit that out...
I tried using <br> anyway, but it doesn't seem to make any use of html tags.

*Edit: Looks like this was caused by the fancy syntax highlighting plugin, which apparently tries to convert all urls into hyperlinks.
« Last Edit: November 10, 2014, 08:07:33 AM by Sundog »
Logged