@dvcol/neo-svelte
Version:
Neomorphic ui library for svelte 5
70 lines (69 loc) • 2.07 kB
JavaScript
export const NeoErrorType = {
NeoError: 'NeoError',
NeoThemeProvider: 'NeoThemeProvider',
NeoList: 'NeoList',
NeoTab: 'NeoTab',
NeoCollapse: 'NeoCollapse',
NeoForm: 'NeoForm',
};
export const NeoErrorName = {
TargetNotFound: 'Target not found',
InvalidTarget: 'Target is not a valid HTMLElement or ShadowRoot',
};
export class NeoError extends Error {
type;
constructor(message, type = NeoErrorType.NeoError) {
super(`[${type}]: ${message}`);
this.type = type;
}
}
export class NeoErrorThemeProvider extends NeoError {
constructor(message) {
super(message, NeoErrorType.NeoThemeProvider);
}
}
export class NeoErrorThemeTargetNotFound extends NeoErrorThemeProvider {
constructor() {
super(NeoErrorName.TargetNotFound);
}
}
export class NeoErrorThemeInvalidTarget extends NeoErrorThemeProvider {
constructor() {
super(NeoErrorName.InvalidTarget);
}
}
export class NeoErrorThemeContextNotFound extends NeoErrorThemeProvider {
constructor() {
super('No theme context found. Did you forget to wrap your component with `NeoThemeProvider`?');
}
}
export class NeoErrorListSelectDisabled extends NeoError {
constructor() {
super('Cannot select an item in a disabled list.', NeoErrorType.NeoList);
}
}
export class NeoErrorMissingId extends NeoError {
constructor(message = 'A unique ID is required.', type) {
super(message, type);
}
}
export class NeoErrorMissingTabId extends NeoErrorMissingId {
constructor(message) {
super(message, NeoErrorType.NeoTab);
}
}
export class NeoErrorMissingCollapseId extends NeoErrorMissingId {
constructor(message) {
super(message, NeoErrorType.NeoCollapse);
}
}
export class NeoErrorFormMissingId extends NeoErrorMissingId {
constructor(message) {
super(message, NeoErrorType.NeoForm);
}
}
export class NeoErrorFormDuplicateId extends NeoError {
constructor() {
super('Field id already exists', NeoErrorType.NeoForm);
}
}