Enhance error message
This commit is contained in:
parent
eef80a979f
commit
5206710195
@ -176,7 +176,21 @@ module.exports = (_options = {}) => {
|
|||||||
});
|
});
|
||||||
} else if (status === 'reject') {
|
} else if (status === 'reject') {
|
||||||
rejects[action](payload);
|
rejects[action](payload);
|
||||||
throw Error(payload);
|
throw Error(
|
||||||
|
`${payload}
|
||||||
|
|
||||||
|
To get more informaion for debugging, please add logger in createWorker():
|
||||||
|
|
||||||
|
const worker = createWorker({
|
||||||
|
logger: ({ message }) => console.log(message),
|
||||||
|
});
|
||||||
|
|
||||||
|
Even more details:
|
||||||
|
|
||||||
|
const { setLogging } = require('@ffmpeg/ffmpeg');
|
||||||
|
setLogging(true);
|
||||||
|
`,
|
||||||
|
);
|
||||||
} else if (status === 'progress') {
|
} else if (status === 'progress') {
|
||||||
parseProgress(payload, progress);
|
parseProgress(payload, progress);
|
||||||
logger(payload);
|
logger(payload);
|
||||||
|
@ -3,13 +3,15 @@ const defaultArgs = require('./constants/defaultArgs');
|
|||||||
const strList2ptr = require('./utils/strList2ptr');
|
const strList2ptr = require('./utils/strList2ptr');
|
||||||
const getTransferables = require('../utils/getTransferables');
|
const getTransferables = require('../utils/getTransferables');
|
||||||
|
|
||||||
|
const NO_LOAD_ERROR = 'FFmpegCore is not ready, make sure you have completed Worker.load().';
|
||||||
|
|
||||||
let action = 'unknown';
|
let action = 'unknown';
|
||||||
let Module = null;
|
let Module = null;
|
||||||
let adapter = null;
|
let adapter = null;
|
||||||
let ffmpeg = null;
|
let ffmpeg = null;
|
||||||
|
|
||||||
const load = ({ workerId, payload: { options: { corePath } } }, res) => {
|
const load = ({ workerId, payload: { options: { corePath } } }, res) => {
|
||||||
if (Module == null) {
|
if (Module === null) {
|
||||||
const Core = adapter.getCore(corePath);
|
const Core = adapter.getCore(corePath);
|
||||||
Core()
|
Core()
|
||||||
.then(async (_Module) => {
|
.then(async (_Module) => {
|
||||||
@ -33,10 +35,14 @@ const FS = ({
|
|||||||
args,
|
args,
|
||||||
},
|
},
|
||||||
}, res) => {
|
}, res) => {
|
||||||
|
if (Module === null) {
|
||||||
|
throw NO_LOAD_ERROR;
|
||||||
|
} else {
|
||||||
res.resolve({
|
res.resolve({
|
||||||
message: `Complete ${method}`,
|
message: `Complete ${method}`,
|
||||||
data: Module.FS[method](...args),
|
data: Module.FS[method](...args),
|
||||||
});
|
});
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const run = ({
|
const run = ({
|
||||||
@ -44,11 +50,15 @@ const run = ({
|
|||||||
args: _args,
|
args: _args,
|
||||||
},
|
},
|
||||||
}, res) => {
|
}, res) => {
|
||||||
|
if (Module === null) {
|
||||||
|
throw NO_LOAD_ERROR;
|
||||||
|
} else {
|
||||||
const args = [...defaultArgs, ..._args.trim().split(' ')].filter((s) => s.length !== 0);
|
const args = [...defaultArgs, ..._args.trim().split(' ')].filter((s) => s.length !== 0);
|
||||||
ffmpeg(args.length, strList2ptr(Module, args));
|
ffmpeg(args.length, strList2ptr(Module, args));
|
||||||
res.resolve({
|
res.resolve({
|
||||||
message: `Complete ${args.join(' ')}`,
|
message: `Complete ${args.join(' ')}`,
|
||||||
});
|
});
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
exports.dispatchHandlers = (packet, send) => {
|
exports.dispatchHandlers = (packet, send) => {
|
||||||
|
Loading…
Reference in New Issue
Block a user