Exemple #1
0
        internal static void ProcessRegistryMetadataFromJSON(string metadata, Registry registry, string filename)
        {
            log.DebugFormat("Converting metadata from JSON.");

            try
            {
                CfanModule module = CfanFileManager.fromJson(metadata);
                log.InfoFormat("Found {0} version {1}", module.identifier, module.modVersion);
                registry.AddAvailable(module);
            }
            catch (Exception exception)
            {
                // Alas, we can get exceptions which *wrap* our exceptions,
                // because json.net seems to enjoy wrapping rather than propagating.
                // See KSP-CKAN/CKAN-meta#182 as to why we need to walk the whole
                // exception stack.

                bool handled = false;

                while (exception != null)
                {
                    if (exception is UnsupportedKraken || exception is BadMetadataKraken)
                    {
                        // Either of these can be caused by data meant for future
                        // clients, so they're not really warnings, they're just
                        // informational.

                        log.InfoFormat("Skipping {0} : {1}", filename, exception.Message);

                        // I'd *love a way to "return" from the catch block.
                        handled = true;
                        break;
                    }

                    // Look further down the stack.
                    exception = exception.InnerException;
                }

                // If we haven't handled our exception, then it really was exceptional.
                if (handled == false)
                {
                    // In case whatever's calling us is lazy in error reporting, we'll
                    // report that we've got an issue here.
                    log.ErrorFormat("Error processing {0} : {1}", filename, exception.Message);
                    throw;
                }
            }
        }
Exemple #2
0
 public static CfanModule kOS_014_module()
 {
     return(CfanFileManager.fromJson(kOS_014()));
 }
Exemple #3
0
 public static CfanModule DogeCoinFlag_101_module()
 {
     return(CfanFileManager.fromJson(DogeCoinFlag_101()));
 }