feat: better error messages
This commit is contained in:
parent
9b4621c4b2
commit
58211410d1
|
|
@ -125,11 +125,10 @@ export class MediaService {
|
|||
|
||||
// @ts-ignore
|
||||
const functionToCall = video.instance[functionName];
|
||||
if (typeof functionToCall !== 'function') {
|
||||
throw new Error(`Function ${functionName} not found on video instance`);
|
||||
if (typeof functionToCall !== 'function' || this._videoManager.checkAvailableVideoFunction(functionToCall)) {
|
||||
throw new HttpException(`Function ${functionName} not found on video instance`, 400);
|
||||
}
|
||||
|
||||
this._videoManager.checkAvailableVideoFunction(functionToCall);
|
||||
return functionToCall(body);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,12 +24,7 @@ export class VideoManager {
|
|||
|
||||
checkAvailableVideoFunction(method: any) {
|
||||
const videoFunction = Reflect.getMetadata('video-function', method);
|
||||
if (!videoFunction) {
|
||||
throw new Error(
|
||||
`Method ${method.name} is not a valid video function.`
|
||||
);
|
||||
}
|
||||
return videoFunction;
|
||||
return !videoFunction;
|
||||
}
|
||||
|
||||
getVideoByName(
|
||||
|
|
|
|||
Loading…
Reference in New Issue