A mighty Meteor package for displaying errors to users
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.
configure
- takesoptions
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 errorsclearOne
- takes errorid
; removes one errorget
- takes an optionalid
; gets one error or, if no argument is passed, gets all errorsgetUnseen
- gets all unseen errors (those that haven't been rendered)restoreDefaults
- resets the options objectsetSeen
- takes errorid
; sets an error to "seen" AKA rendered to the userstyleDisabled
- returns true if default styles are disabled; false by defaultthrow
- takeserror
message; throws a single, dismissable error to the userthrowList
- takes an array oferrors
and an optionalpreMessage
; displays the pre-message, followed by an unordered listul
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
clearAllEnabled
- (default: false) Set totrue
in order to add a button to the template that clears all errorsignoreRepeats
- (default: false) Set totrue
to ignore repeated errors; errors with the samemessage
will not be added to the collectionnoDismiss
- (default: false) Set totrue
in order to disable the dismiss/close error message buttonstyleDisabled
- (default: false) Set totrue
in order to disable the default CSS styles. Note: the css file will still load but thedefault-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