<commit_before>devices =
    MediaServer: require "./devices/MediaServer"

upnp =
    createDevice: (name, type) -> new devices[type](name)

module.exports = upnp
<commit_msg>Add some basic error handling when creating devices<commit_after># Currently implemented devices
deviceList = [ 'MediaServer' ]

devices = {}
for deviceType in deviceList
    # device classes are in devices/<DeviceType>.coffee
    devices[deviceType] = require "./devices/#{deviceType}"

exports.createDevice = (name, type) ->
    if not type in deviceList
        return new Error "UPnP device of type #{type} is not yet implemented."

    return new devices[type](name)

{'fraction_non_alphanumeric': 0.10510046367851623, 'fraction_numerical': 0.0, 'mean_word_length': 4.184, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 6, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '456453', 'n_tokens_mistral': 181, 'n_tokens_neox': 178, 'n_words': 61}