From 76e5cc1d78d48d8821673a92b224e9378886c97a Mon Sep 17 00:00:00 2001 From: jaipaljadeja Date: Sat, 13 Apr 2024 02:56:04 +0530 Subject: [PATCH] fix: compile and runtime error messaging --- components/Editor/index.tsx | 11 +++++++---- components/Tracer/index.tsx | 2 +- context/cairoVMApiContext.tsx | 2 +- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/components/Editor/index.tsx b/components/Editor/index.tsx index 64b8353..0ffb738 100644 --- a/components/Editor/index.tsx +++ b/components/Editor/index.tsx @@ -183,14 +183,17 @@ const Editor = ({ readOnly = false }: Props) => { if (serializedOutput) { addToConsoleLog(`Execution output: ${serializedOutput}`) } + + if (executionState === ProgramExecutionState.Error) { + addToConsoleLog( + 'Runtime error: ' + executionPanicMessage, + LogType.Error, + ) + } } else if (compilationState === ProgramCompilationState.CompilationErr) { addToConsoleLog('Compilation failed', LogType.Error) } - if (executionState === ProgramExecutionState.Error) { - addToConsoleLog('Runtime error: ' + executionPanicMessage, LogType.Error) - } - // Compilation finished, log the API logs, if any for (const apiLogEntry of apiLogs) { let log_type diff --git a/components/Tracer/index.tsx b/components/Tracer/index.tsx index d60f067..8e026cd 100644 --- a/components/Tracer/index.tsx +++ b/components/Tracer/index.tsx @@ -253,7 +253,7 @@ export const Tracer = () => { -
+
{selectedConsoleTab === IConsoleTab.Console && } {selectedConsoleTab === IConsoleTab.DebugInfo && ( diff --git a/context/cairoVMApiContext.tsx b/context/cairoVMApiContext.tsx index d7d2d6b..9dcb7e6 100644 --- a/context/cairoVMApiContext.tsx +++ b/context/cairoVMApiContext.tsx @@ -196,6 +196,7 @@ export const CairoVMApiProvider: React.FC = ({ ? ProgramCompilationState.CompilationSuccess : ProgramCompilationState.CompilationErr, ) + setLogs(data.logs) setExecutionState( data.is_execution_successful === true ? ProgramExecutionState.Success @@ -211,7 +212,6 @@ export const CairoVMApiProvider: React.FC = ({ setSierraCode(data.sierra_program_code) setCairoLangCompilerVersion(data.cairo_lang_compiler_version) setSerializedOutput(data.serialized_output) - setLogs(data.logs) setExecutionPanicMessage(data.execution_panic_message) setTracerData({ memory: data.tracer_data.memory,