Files
speckle-server/packages/server/modules/shared/errors/index.js
T
Kristaps Fabians Geikins da9224a069 feat: server & stream invites rework
feat: server & stream invites rework

Co-authored-by: Dimitrie Stefanescu <didimitrie@gmail.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2022-07-19 13:01:19 +03:00

68 lines
1.8 KiB
JavaScript

const { BaseError } = require('./base')
class ForbiddenError extends BaseError {
static code = 'FORBIDDEN_ERROR'
static defaultMessage = 'Access to the resource is forbidden'
}
/**
* Use this in logic branches that should never execute, and if they do - it means
* there's most definitely a bug in the code
*/
class LogicError extends BaseError {
static code = 'LOGIC_ERROR'
static defaultMessage = 'An unexpected issue occurred'
}
/**
* Use this to throw when user tries to access data that he shouldn't have access to
*/
class UnauthorizedError extends BaseError {
static code = 'UNAUTHORIZED_ACCESS_ERROR'
static defaultMessage = 'Attempted unauthorized access to data'
}
class NotFoundError extends BaseError {
static code = 'NOT_FOUND_ERROR'
static defaultMessage = "These aren't the droids you're looking for."
}
class BadRequestError extends BaseError {
static code = 'BAD_REQUEST_ERROR'
static defaultMessage = 'The request contains invalid data'
}
class ResourceMismatch extends BaseError {
static code = 'BAD_REQUEST_ERROR'
static defaultMessage = 'The target resources mismatch'
}
/**
* Use this to validate args
*/
class InvalidArgumentError extends BaseError {
static code = 'INVALID_ARGUMENT_ERROR'
static defaultMessage = 'Invalid arguments received'
}
class RichTextParseError extends BaseError {
static code = 'RICH_TEXT_PARSE_ERROR'
static defaultMessage =
'An error occurred while trying to parse the rich text document'
}
class ContextError extends BaseError {
static code = 'CONTEXT_ERROR'
static defaultMessage = 'The context is missing from the request'
}
module.exports = {
BadRequestError,
ForbiddenError,
UnauthorizedError,
NotFoundError,
ResourceMismatch,
InvalidArgumentError,
RichTextParseError,
ContextError,
LogicError
}