Skip to content

🎥 Make videos programmatically with React

error printing is much better

Jonny Burger91920970f939
diff --git a/packages/cli/src/print-error.ts b/packages/cli/src/print-error.ts
index c40c839020..79240054bd 100644
--- a/packages/cli/src/print-error.ts
+++ b/packages/cli/src/print-error.ts
@@ -8,16 +8,21 @@ import {shouldUseNonOverlayingLogger} from './should-use-non-overlaying-logger';
export const printError = async (err: Error, logLevel: LogLevel) => {
if (err instanceof RenderInternals.SymbolicateableError) {
+ const updatesDoOverwrite = !shouldUseNonOverlayingLogger({logLevel});
const output = createOverwriteableCliOutput({
quiet: false,
cancelSignal: null,
- updatesDontOverwrite: shouldUseNonOverlayingLogger({logLevel}),
+ updatesDontOverwrite: !updatesDoOverwrite,
indent: false,
});
- output.update(
- chalk.red('Symbolicating minified error message...\n' + err.message),
- false
- );
+
+ if (updatesDoOverwrite) {
+ output.update(
+ chalk.red('Symbolicating minified error message...\n' + err.message),
+ false
+ );
+ }
+
try {
const symbolicated = await RenderInternals.symbolicateError(err);
if (symbolicated.frame === null) {
@@ -31,12 +36,7 @@ export const printError = async (err: Error, logLevel: LogLevel) => {
printCodeFrameAndStack(symbolicated);
} catch (e) {
- output.update(
- chalk.red(
- '(Error occurred symbolicating stack trace - printing minified stack trace)'
- ),
- true
- );
+ output.update(chalk.red(''), true);
Log.error();
Log.error(err.stack || err);
}
diff --git a/packages/lambda/src/cli/commands/still.ts b/packages/lambda/src/cli/commands/still.ts
index 28980320dd..8b7964b9f3 100644
--- a/packages/lambda/src/cli/commands/still.ts
+++ b/packages/lambda/src/cli/commands/still.ts
@@ -116,70 +116,49 @@ export const stillCommand = async (args: string[], remotionRoot: string) => {
ConfigInternals.getUserPreferredStillImageFormat() ?? null,
});
- try {
- Log.info(
- CliInternals.chalk.gray(
- `functionName = ${functionName}, imageFormat = ${imageFormat} (${imageFormatReason})`
- )
- );
+ Log.info(
+ CliInternals.chalk.gray(
+ `functionName = ${functionName}, imageFormat = ${imageFormat} (${imageFormatReason})`
+ )
+ );
+
+ const res = await renderStillOnLambda({
+ functionName,
+ serveUrl,
+ inputProps,
+ imageFormat,
+ composition,
+ privacy,
+ region,
+ maxRetries,
+ envVariables,
+ frame: stillFrame,
+ jpegQuality,
+ logLevel,
+ outName,
+ chromiumOptions,
+ timeoutInMilliseconds: puppeteerTimeout,
+ scale,
+ forceHeight: height,
+ forceWidth: width,
+ onInit: ({cloudWatchLogs, renderId}) => {
+ Log.info(CliInternals.chalk.gray(`Render invoked with ID = ${renderId}`));
+ Log.verbose(`CloudWatch logs (if enabled): ${cloudWatchLogs}`);
+ },
+ });
- const res = await renderStillOnLambda({
- functionName,
- serveUrl,
- inputProps,
- imageFormat,
- composition,
- privacy,
+ if (downloadName) {
+ Log.info('Finished rendering. Downloading...');
+ const {outputPath, sizeInBytes} = await downloadMedia({
+ bucketName: res.bucketName,
+ outPath: downloadName,
region,
- maxRetries,
- envVariables,
- frame: stillFrame,
- jpegQuality,
- logLevel,
- outName,
- chromiumOptions,
- timeoutInMilliseconds: puppeteerTimeout,
- scale,
- forceHeight: height,
- forceWidth: width,
- onInit: ({cloudWatchLogs, renderId}) => {
- Log.info(
- CliInternals.chalk.gray(`Render invoked with ID = ${renderId}`)
- );
- Log.verbose(`CloudWatch logs (if enabled): ${cloudWatchLogs}`);
- },
+ renderId: res.renderId,
});
-
- if (downloadName) {
- Log.info('Finished rendering. Downloading...');
- const {outputPath, sizeInBytes} = await downloadMedia({
- bucketName: res.bucketName,
- outPath: downloadName,
- region,
- renderId: res.renderId,
- });
- Log.info('Done!', outputPath, CliInternals.formatBytes(sizeInBytes));
- } else {
- Log.info(`Finished still!`);
- Log.info();
- Log.info(res.url);
- }
- } catch (err) {
- const frames = RenderInternals.parseStack(
- ((err as Error).stack ?? '').split('\n')
- );
-
- const errorWithStackFrame = new RenderInternals.SymbolicateableError({
- message: (err as Error).message,
- frame: null,
- name: (err as Error).name,
- stack: (err as Error).stack,
- stackFrame: frames,
- });
- await CliInternals.handleCommonError(
- errorWithStackFrame,
- RenderInternals.getLogLevel()
- );
- quit(1);
+ Log.info('Done!', outputPath, CliInternals.formatBytes(sizeInBytes));
+ } else {
+ Log.info(`Finished still!`);
+ Log.info();
+ Log.info(res.url);
}
};
diff --git a/packages/lambda/src/cli/index.ts b/packages/lambda/src/cli/index.ts
index e48817a67e..2682cc80b2 100644
--- a/packages/lambda/src/cli/index.ts
+++ b/packages/lambda/src/cli/index.ts
@@ -22,6 +22,7 @@ import {printHelp} from './help';
import {quit} from './helpers/quit';
import {setIsCli} from './is-cli';
import {Log} from './log';
+import {ConfigInternals} from '@remotion/cli/config';
const requiresCredentials = (args: string[]) => {
if (args[0] === POLICIES_COMMAND) {
@@ -179,7 +180,27 @@ AWS returned an error message "The security token included in the request is inv
);
}
- Log.error(error.stack);
+ if (error instanceof RenderInternals.SymbolicateableError) {
+ await CliInternals.handleCommonError(
+ error,
+ ConfigInternals.Logging.getLogLevel()
+ );
+ } else {
+ const frames = RenderInternals.parseStack(error.stack?.split('\n') ?? []);
+
+ const errorWithStackFrame = new RenderInternals.SymbolicateableError({
+ message: error.message,
+ frame: null,
+ name: error.name,
+ stack: error.stack,
+ stackFrame: frames,
+ });
+ await CliInternals.handleCommonError(
+ errorWithStackFrame,
+ ConfigInternals.Logging.getLogLevel()
+ );
+ }
+
quit(1);
}
};