CloudNet-v2 icon indicating copy to clipboard operation
CloudNet-v2 copied to clipboard

Add more error handling

Open GiantTreeLP opened this issue 5 years ago • 2 comments

Some places in the cloud need more error tolerance.

Examples:

  • loading of modules (ModuleDetector)
  • loading the configuration

And more things, primarily in the master and the bridge.

GiantTreeLP avatar Aug 05 '19 16:08 GiantTreeLP

Issue-Label Bot is automatically applying the label feature_request to this issue, with a confidence of 0.88. Please mark this comment with :thumbsup: or :thumbsdown: to give our bot feedback!

Links: app homepage, dashboard and code for this bot.

issue-label-bot[bot] avatar Aug 05 '19 16:08 issue-label-bot[bot]

We should consider using the logger to output the errors instead of always doing a printStackTrace. That way we can identify a better error and include a separate message for each error! Here is an example:

Before

    /**
    * Copy folder
    *
    * @param name The name of the folder.
    */
    public void copyDirectory(String name) {
        File file = new File(path, name);

        if (file.exists() && file.isDirectory()) {
            try {
                FileUtility.copyFilesInDirectory(file,
                                                 new File("local/templates/" + serverGroup.getName() + NetworkUtils.SLASH_STRING + serverProcess
                                                     .getMeta()
                                                     .getTemplate()
                                                     .getName() + NetworkUtils.SLASH_STRING + name));
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }

After

   /**
    * Copy folder
    *
    * @param name The name of the folder.
    */
    public void copyDirectory(String name) {
        File file = new File(path, name);

        if (file.exists() && file.isDirectory()) {
            try {
                FileUtility.copyFilesInDirectory(file,
                                                 new File("local/templates/" + serverGroup.getName() + NetworkUtils.SLASH_STRING + serverProcess
                                                     .getMeta()
                                                     .getTemplate()
                                                     .getName() + NetworkUtils.SLASH_STRING + name));
            } catch (IOException e) {
                CloudNetWrapper.getInstance().getCloudNetLogging().log(Level.SEVERE, "An unexpected error occurred while copying a folder ", e);
            }
        }
    }

TheMeinerLP avatar Jun 29 '20 11:06 TheMeinerLP