Socket
Socket
Sign inDemoInstall

vue-error

Package Overview
Dependencies
1
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    vue-error

A simple Vue wrapper on StandardError.js, providing a simple yet powerful way to deal with errors


Version published
Weekly downloads
21
increased by250%
Maintainers
1
Created
Weekly downloads
 

Readme

Source

Vue Error

A simple Vue wrapper on StandardError.js, providing a simple yet powerful way to deal with errors

Installing

Using npm :

npm install vue-error

Using yarn :

yarn add vue-error

Setup

Import ES6 module style :

import Vue from 'vue'
import StandardError from 'vue-error'

Or CommonJS style :

const Vue = require('vue')
  , StandardError = require('vue-error')

Or AMD style :

define(['vue', 'vue-error'], function(Vue, StandardError) {})

Or even <script> style :

<script src="http://path/to/vue.js"></script>
<script src="http://path/to/vue-error/index.js"></script>

Then provide StandardError to the use() function of Vue :

Vue.use(StandardError)

Useage

You can now use $StandardError in your Vue instances and components

// Example useage, to separate planned errors

new Vue({
  created() {
    this.$http.put('/api/user/', payloadObject)
    .then((res) => {
      if (res.data.error) throw new this.$StandardError(res.data.error)
      if (res.data.success) // Do something with response
    })
    .catch(this.$StandardError, err => // Show a res.data.error custom message to the client)
    .catch(err => // Keep in console or report for debugging) 
  }
})
  • Have a look at vue-axios to implement this.$http

  • And at bluebird for full featured promise with unmatched performance

Dependencies

  • StandardError.js - A tiny JavaScript library that simplifies creating subclasses of Error for custom error classes

License

This project is licensed under the MIT License - see the LICENSE.md file for details

Keywords

FAQs

Last updated on 13 May 2018

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc