Skip to content

[Question] Why prepend message with a colon? #78

Description

@blackdynamo

Is there a reason why you prepend : before appending the cause message? I might be missing something deeper in the library that requires that additional colon. I have noticed it when trying to use the VError library and it's adding the "unexpected" : .

https://github.com/joyent/node-verror/blob/master/lib/verror.js#L185

	if (cause) {
		mod_assertplus.ok(mod_isError(cause), 'cause is not an Error');
		this.jse_cause = cause;

		if (!parsed.options.skipCauseMessage) {
			message += ': ' + cause.message;
		}
	}

The following code:

import {VError} from "verror";

const err = new VError(new Error("Original"));
console.log(err);

Outputs the following:

VError: : Original
    at Object.<anonymous> (example.js:3:13)
    at Module._compile (internal/modules/cjs/loader.js:955:30)
    at Module._compile (/node_modules/pirates/lib/index.js:99:24)
    at Module._extensions..js (internal/modules/cjs/loader.js:991:10)
    at Object.newLoader [as .js] (/node_modules/pirates/lib/index.js:104:7)
    at Module.load (internal/modules/cjs/loader.js:811:32)
    at Function.Module._load (internal/modules/cjs/loader.js:723:14)
    at Function.Module.runMain (internal/modules/cjs/loader.js:1043:10)
    at Object.<anonymous> (/node_modules/@babel/node/lib/_babel-node.js:174:21)
    at Module._compile (internal/modules/cjs/loader.js:955:30) {
  jse_shortmsg: '',
  jse_cause: Error: Original
      at Object.<anonymous> (example.js:3:24)
      at Module._compile (internal/modules/cjs/loader.js:955:30)
      at Module._compile (/node_modules/pirates/lib/index.js:99:24)
      at Module._extensions..js (internal/modules/cjs/loader.js:991:10)
      at Object.newLoader [as .js] (/node_modules/pirates/lib/index.js:104:7)
      at Module.load (internal/modules/cjs/loader.js:811:32)
      at Function.Module._load (internal/modules/cjs/loader.js:723:14)
      at Function.Module.runMain (internal/modules/cjs/loader.js:1043:10)
      at Object.<anonymous> (/node_modules/@babel/node/lib/_babel-node.js:174:21)
      at Module._compile (internal/modules/cjs/loader.js:955:30),
  jse_info: {},
  message: ': Original'
}

Please note the error.message is ": Original" with the colon.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions