Skip to content

Commit 018f587

Browse files
committed
Enhance error message
1 parent 0f400a0 commit 018f587

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

src/browser/getCreateFFmpegCore.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
/* eslint-disable no-undef */
22
const resolveURL = require('resolve-url');
33
const { log } = require('../utils/log');
4+
const {
5+
CREATE_FFMPEG_CORE_IS_NOT_DEFINED,
6+
} = require('../utils/errors');
47

58
/*
69
* Fetch data from remote URL and convert to blob URL
@@ -38,6 +41,9 @@ module.exports = async ({ corePath: _corePath }) => {
3841
const script = document.createElement('script');
3942
const eventHandler = () => {
4043
script.removeEventListener('load', eventHandler);
44+
if (typeof createFFmpegCore === 'undefined') {
45+
throw Error(CREATE_FFMPEG_CORE_IS_NOT_DEFINED(coreRemotePath));
46+
}
4147
log('info', 'ffmpeg-core.js script loaded');
4248
resolve({
4349
createFFmpegCore,

src/utils/errors.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
const CREATE_FFMPEG_CORE_IS_NOT_DEFINED = (corePath) => (`
2+
createFFmpegCore is not defined. ffmpeg.wasm is unable to find createFFmpegCore after loading ffmpeg-core.js from ${corePath}. Use another URL when calling createFFmpeg():
3+
4+
const ffmpeg = createFFmpeg({
5+
corePath: 'http://localhost:3000/ffmpeg-core.js',
6+
});
7+
`);
8+
9+
module.exports = {
10+
CREATE_FFMPEG_CORE_IS_NOT_DEFINED,
11+
};

0 commit comments

Comments
 (0)