  at #{req.client.remoteAddress}."
         handler req, (err, data, customHeaders) =>
             if err?
-                # On error, `data` is an error code. Very rudimentary error
-                # handling, as it is not intended for humans anyway.
-                console.warn "Responded with #{data}: #{err.message} for #{req.url}."
-                res.writeHead data, 'Content-Type': 'text/plain'
-                res.write "#{data} - #{err.message}"
+                console.warn "Responded with #{err.code}: #{err.message} for #{req.url}."
+                res.writeHead err.code, 'Content-Type': 'text/plain'
+                res.write "#{err.code} - #{err.message}"
             else
                 # Make a header object for response.
                 # `null` means use default value.

                            __dirname + '/services/' + serviceType + '.xml'
                            'utf8'
                            (err, file) ->
                                return callback err, 500 if err
                                callback null, file
                        )
                    when 'control'
                        if req.method isnt 'POST' or not req.headers.soapaction?
                            return callback new Error('Method Not Allowed'), 405
                        data = ''
                        req.on 'data', (chunk) ->
                            data += chunk

        switch category
            when 'device'
                if action isnt 'description'
                    return callback new HttpError 404
                @_buildDescription (err, desc) ->
                    return callback new HttpError 500 if err
                    callback null, desc

            when 'service'
