Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@foundry-ai/api-errors

Package Overview
Dependencies
Maintainers
4
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@foundry-ai/api-errors

Common errors that can be thrown and caught reliably across services

  • 0.2.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1
decreased by-92.86%
Maintainers
4
Weekly downloads
 
Created
Source

FoundryAI Standard API Errors

Build Status Version Test Coverage License

Common errors that can be thrown and caught reliably across services

Example

import { InternalError, NotFoundError } from '@foundry-ai/api-errors'

function doWork(callback) {
    try {
        performImpossibleTask(callback)
    } catch {
        throw new InternalError()
    }
}

function findPuppy(puppyId, callback) {
    queryForPuppy(puppyId, function(error, puppy) {
        if (!puppy) throw new NotFoundError('failed to find puppy')

        callback(puppy)
    })
}

Error Classes

All Error classes can be instantiated with custom messages and statuses (given as parameters in that order), but come with sensible defaults.

Error Class.message.code.type
BadRequestError'Bad Request'400'bad_request_error'
AuthenticationError'Unauthorized'401'authentication_error'
ForbiddenError'Forbidden'403'forbidden_error'
NotFoundError'Not Found'404'not_found_error'
ConflictError'Conflict'409'conflict_error'
RateLimitError'Too many requests'429'rate_limit_error'
InternalError'Internal Server Error'500'internal_server_error'

Keywords

FAQs

Package last updated on 14 Aug 2017

Did you know?

Socket

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc