Git Product home page Git Product logo

mighty-errors's Introduction

Mighty Errors

A mighty Meteor package for displaying errors to users

Basic Usage

Display the error template:

{{> mightyErrors}}

Throw an error:

try {
  // some lovely code here
} catch(error) {
  Errors.throw(error.message);
}

Or throw an error list with an optional preceeding message:

Errors.throwList(['One error', 'Two errors', 'Red fish', 'Blue fish'], 'These are your errors:');

For more advanced use cases, you can use the package methods directly, instead of loading the mightyErrors template.

Methods

  • configure - takes options object; sets options (see below)
  • clearSeen - removes all seen errors (i.e. those that have been rendered to the user)
  • clearAll - removes all seen and unseen errors
  • clearOne - takes error id; removes one error
  • get - takes an optional id; gets one error or, if no argument is passed, gets all errors
  • getUnseen - gets all unseen errors (those that haven't been rendered)
  • restoreDefaults - resets the options object
  • setSeen - takes error id; sets an error to "seen" AKA rendered to the user
  • styleDisabled - returns true if default styles are disabled; false by default
  • throw - takes error message; throws a single, dismissable error to the user
  • throwList - takes an array of errors and an optional preMessage; displays the pre-message, followed by an unordered list ul of errors. Useful for displaying errors in processing data, where there may be a bunch of errors that you don't want the user to have to dismiss a dozen rows related to the same data error

Options

  • clearAllEnabled - (default: false) Set to true in order to add a button to the template that clears all errors
  • ignoreRepeats - (default: false) Set to true to ignore repeated errors; errors with the same message will not be added to the collection
  • noDismiss - (default: false) Set to true in order to disable the dismiss/close error message button
  • styleDisabled - (default: false) Set to true in order to disable the default CSS styles. Note: the css file will still load but the default-style class will not be appended to the error container so the styles won't be applied

Note: Errors.options is currently non-reactive, so changes will not re-render the template

mighty-errors's People

Contributors

francisbyrne avatar

Stargazers

 avatar

Watchers

 avatar  avatar

mighty-errors's Issues

Make Options reactive

Currently Errors.options is not reactive, so any call to Errors.configure after the template has rendered are pointless.

It would be much more effective if this behaved reactively so you could e.g. have Clear All button for some pages but not others.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.