Skip to content

Commit

Permalink
Improve some debug output
Browse files Browse the repository at this point in the history
  • Loading branch information
Supereg committed Sep 15, 2020
1 parent 1c65fc6 commit 5a17e64
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/MDNSServer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ export class MDNSServer {
}

return new Promise((resolve, reject) => {
const errorHandler = (error: Error | number): void => reject(error);
const errorHandler = (error: Error): void => reject(new Error("Failed to bind on interface " + name + ": " + error.message));
socket.once("error", errorHandler);

socket.bind(MDNSServer.MDNS_PORT, () => {
Expand All @@ -295,7 +295,7 @@ export class MDNSServer {

const multicastAddress = family === IPFamily.IPv4? MDNSServer.MULTICAST_IPV4: MDNSServer.MULTICAST_IPV6;
const interfaceAddress = family === IPFamily.IPv4? networkInterface!.ipv4: networkInterface!.ipv6;
assert(interfaceAddress, "Interface address cannot be undefined!");
assert(interfaceAddress, "Interface address for " + name + " cannot be undefined!");

socket.addMembership(multicastAddress, interfaceAddress!);

Expand Down Expand Up @@ -376,7 +376,7 @@ export class MDNSServer {
}

if (callback) {
callback(error.error);
callback(new Error("Encountered socket error on " + error.name + ": " + error.error.stack));
} else {
MDNSServer.handleSocketError(error.name, error.error);
}
Expand Down
7 changes: 7 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,18 @@ if (version.includes("beta") || process.env.BCT) { // enable debug output if bet
import "./coder/records/index";
import { MDNSServerOptions } from "./MDNSServer";
import { Responder } from "./Responder";
import createDebug from "debug";

export * from "./CiaoService";
export * from "./Responder";
export { MDNSServerOptions } from "./MDNSServer";

function printInitInfo() {
const debug = createDebug("ciao:init");
debug("Loading ciao v" + version + "...");
}
printInitInfo();

/**
* Defines the transport protocol of a service.
*
Expand Down

0 comments on commit 5a17e64

Please sign in to comment.