beaker-error-constants
Version:
Module containing the errors used by beaker and its submodules
165 lines (144 loc) • 4.5 kB
JavaScript
class ExtendableError extends Error {
constructor(msg) {
super(msg)
this.name = this.constructor.name
this.message = msg
if (typeof Error.captureStackTrace === 'function') {
Error.captureStackTrace(this, this.constructor)
} else {
this.stack = (new Error(msg)).stack
}
}
}
exports.NotFoundError = class NotFoundError extends ExtendableError {
constructor(msg) {
super(msg || 'File not found')
this.notFound = true
}
}
exports.NotAFileError = class NotAFileError extends ExtendableError {
constructor(msg) {
super(msg || 'Target must be a file')
this.notAFile = true
}
}
exports.NotAFolderError = class NotAFolderError extends ExtendableError {
constructor(msg) {
super(msg || 'Target must be a folder')
this.notAFolder = true
}
}
exports.NotAvailableError = class NotAvailableError extends ExtendableError {
constructor(msg) {
super(msg || 'The file or folder is not currently being hosted by any connectable peers')
this.notAFolder = true
}
}
exports.InvalidEncodingError = class InvalidEncodingError extends ExtendableError {
constructor(msg) {
super(msg || 'Invalid encoding')
this.invalidEncoding = true
}
}
exports.TimeoutError = class TimeoutError extends ExtendableError {
constructor(msg) {
super(msg || 'Timed out')
this.timedOut = true
}
}
exports.ArchiveNotWritableError = class ArchiveNotWritableError extends ExtendableError {
constructor(msg) {
super(msg || 'Cannot write to this archive ; Not the owner')
this.archiveNotWritable = true
}
}
exports.EntryAlreadyExistsError = class EntryAlreadyExistsError extends ExtendableError {
constructor(msg) {
super(msg || 'A file or folder already exists at this path')
this.entryAlreadyExists = true
}
}
exports.ParentFolderDoesntExistError = class ParentFolderDoesntExistError extends ExtendableError {
constructor(msg) {
super(msg || 'Cannot write to this location ; No parent folder exists')
this.parentFolderDoesntExist = true
}
}
exports.InvalidPathError = class InvalidPathError extends ExtendableError {
constructor(msg) {
super(msg || 'The given path is not valid')
this.invalidPath = true
}
}
exports.SourceNotFoundError = class SourceNotFoundError extends ExtendableError {
constructor(msg) {
super(msg || 'Cannot read a file or folder at the given source path')
this.sourceNotFound = true
}
}
exports.DestDirectoryNotEmpty = class DestDirectoryNotEmpty extends ExtendableError {
constructor(msg) {
super(msg || 'Destination path is not empty ; Aborting')
this.destDirectoryNotEmpty = true
}
}
exports.ProtocolSetupError = class ProtocolSetupError extends ExtendableError {
constructor(msg) {
super(msg || 'Error setting up the URL protocol')
this.protocolSetupError = true
}
}
exports.UserDeniedError = class UserDeniedError extends ExtendableError {
constructor(msg) {
super(msg || 'User denied permission')
this.permissionDenied = true
}
}
exports.PermissionsError = class PermissionsError extends ExtendableError {
constructor(msg) {
super(msg || 'Permissions denied')
this.permissionDenied = true
}
}
exports.QuotaExceededError = class QuotaExceededError extends ExtendableError {
constructor(msg) {
super(msg || 'Disk space quota exceeded')
this.quotaExceeded = true
}
}
exports.SourceTooLargeError = class SourceTooLargeError extends ExtendableError {
constructor(msg) {
super(msg || 'The source file is too large')
this.sourceTooLarge = true
}
}
exports.InvalidURLError = class InvalidURLError extends ExtendableError {
constructor(msg) {
super(msg || 'Invalid URL')
this.invalidUrl = true
}
}
exports.InvalidArchiveKeyError = class InvalidArchiveKeyError extends ExtendableError {
constructor(msg) {
super(msg || 'Invalid archive key')
this.invalidArchiveKey = true
}
}
exports.InvalidDomainName = class InvalidDomainName extends ExtendableError {
constructor(msg) {
super(msg || 'Invalid domain name')
this.invalidDomainName = true
}
}
exports.ProtectedFileNotWritableError = class ProtectedFileNotWritableError extends ExtendableError {
constructor(msg) {
super(msg || 'Protected file is not wrtable')
this.protectedFileNotWritable = true
}
}
exports.ModalActiveError = class ModalActiveError extends ExtendableError {
constructor(msg) {
super(msg || 'Modal already active')
this.modalActive = true
}
}