media-type-detector
Version:
Detects and categorizes media files (image, video, document, etc.) from a Blob using file-type.
19 lines (18 loc) • 691 B
JavaScript
export class MediaDetectionError extends Error {
constructor(message, originalError) {
super(message);
this.name = 'MediaDetectionError';
this.originalError = originalError;
// Append original error stack if available
if (originalError instanceof Error) {
this.stack += '\nCaused by: ' + originalError.stack;
}
else if (typeof originalError === 'string') {
this.stack += '\nCaused by: ' + originalError;
}
// Maintains proper stack trace (for V8 environments like Node)
if (Error.captureStackTrace) {
Error.captureStackTrace(this, MediaDetectionError);
}
}
}