
Research
/Security News
77 Firefox Extensions Linked to Crypto Wallet and Credential Theft
Socket uncovered 77 linked Firefox extensions, including 40 that steal wallet secrets or credentials and 37 deceptive sports-score shells.
msg-switch
Advanced tools
An easy way to display error messages for a predefined set of error codes.
During our transition from AngularJS (v1.6.x) to VueJS, we encountered a problem. We struggled to find an easy way to migrate an AngularJS component relying on ngMessages directive.
The requirements are as follows:
In this basic example the components are used to display an error message based on an error code. Basically, it behaves as a huge switch statement: chooses the right message to be displayed. But unlike a switch statement it should be able
// StdError.vue
<MsgSwitch :value="code">
<!--
User-defined custom messages comes first,
such that they overwrite the default messages.
-->
<slot :value="value" />
<!-- Here the standard error messages come -->
<MsgCase when="unautheticated">Please log in!</MsgCase>
<MsgCase when="not_found">Not found.</MsgCase>
<MsgCase when="forbidden">You do not enough permissions.</MsgCase>
<!-- A standrard wildcard case. -->
<MsgCase when="*">
<template slot-scope="{ value }">
Unknown error: <pre>{{value}}</pre>.
</template>
</MsgCase>
</MsgSwitch>
Than this component is used as follows:
// App.vue
<StdError :value="error.code">
<MsgCase when="not_found">The document was not found.</MsgCase>
<MsgCase when="forbidden">You are not allowed to edit the document.</MsgCase>
<MsgCase when="dynamic">Message for error code missing in StdError.</MsgCase>
</StdError>
In the example above the following scenarios are possible:
unautheticated, the standard error message listed in
StdError would be displayed: Please log in!.not_found, the custom error message would be displayed:
The document was not found..dynamic, the custom error message would be displayed:
Message for error code missing in StdError..In this example an additional context is passed to MsgSwitch. This context is
treated as an opaque value and is passed as is to MsgCase components.
It can be used inside MsgCase components using
scoped slots as
show below.
// StdErrorWithContext.vue
<MsgSwitch :value="code" :ctx="someObject">
<!--
User-defined custom messages comes first,
such that they overwrite the default messages.
-->
<slot :value="value" />
<!-- Here the standard error messages come -->
<MsgCase when="unautheticated">Please log in!</MsgCase>
<MsgCase when="not_found">
<template slot-scope="{ ctx }">
Resource {{ ctx.id }} was not found.
</template>
</MsgCase>
<MsgCase when="forbidden">
<template slot-scope="{ ctx }">
You do not enough permissions to {{ ctx.method }} {{ ctx.resourceName }}.
</template>
</MsgCase>
<!-- A standrard wildcard case. -->
<MsgCase when="*">
<template slot-scope="{ ctx, value }">
Unknown error (<code>{{value}}</code>): <pre>{{ ctx }}</pre>.
</template>
</MsgCase>
</MsgSwitch>
Than this component is used as follows:
// App.vue
<StdErrorWithContext :value="error.code">
<MsgCase when="not_found">
<template slot-scope="{ ctx }">
User {{ ctx.id }} was not found.
</template>
</MsgCase>
<MsgCase when="dynamic">
<template slot-scope="{ ctx }">
Message for error code missing in StdError:
<pre>{{ ctx.someDebugInfo }}</pre>.
</template>
</MsgCase>
</StdErrorWithContext>
npm install
npm run serve
npm run build
npm run test
npm run lint
npm run test:unit
FAQs
An easy way to display error messages for a predefined set of error codes.
The npm package msg-switch receives a total of 4 weekly downloads. As such, msg-switch popularity was classified as not popular.
We found that msg-switch demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Research
/Security News
Socket uncovered 77 linked Firefox extensions, including 40 that steal wallet secrets or credentials and 37 deceptive sports-score shells.

Security News
NIST disclosed an unreleased AI tool called V-etalon and opened a broad inquiry into NVD modernization after years of automation plans produced no public enrichment system.

Security News
In his AI Council 2026 talk, Feross Aboukhadijeh covers recent package compromises, vulnerability discovery, and a more automated security model.