Skip to content

Coggle/critical-error

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

27 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

critical-error

NPM Version

Provides a simple interface to send messages to a pre-configured SNS endpoint, using @aws-sdk/client-sns.

All messages are also logged to console.error.

A process uncaughtException handler is also installed which logs uncaught exceptions.

Install

npm i critical-error

Usage

var critical = require('critical-error');

// configure somewhere once before use:
critical.configure({TopicArn:"arn:aws:yourarnhere", region:"the-topics-region"});

critical("Oh no! Super bad error D:")

Options

All options are passed to the AWS SDK PublishCommand creation, apart from region which is used when creating the AWS SNS Client object.

Usage in shortlived processes

critical() is asynchronous but does not provide a callback (since there is no sensible way to handle errors). If you need to wait for messages to be sent (for instance due to running as a serverless function), then use:

// call callback when an in-flight critical() request is completed:
critical.waitForCompletion(callback);

// await the completion of an inflight request:
await critical.waitForCompletion();

Changelog

1.3.1

  • fixed respository URL in package.json for provenance

1.3.0

  • updated AWS SDK version, add provenance-attested publish from github action

1.2.0

  • add .waitForCompletion()

1.1.0

  • Updated to use aws-sdk v3, depending only on @aws-sdk/client-sns instead of the whole sdk

About

A simple interface to send error messages to an SNS topic.

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors