Skip to content
This repository has been archived by the owner on Mar 9, 2023. It is now read-only.

Commit

Permalink
Fix: error format and color diagnostics (#20)
Browse files Browse the repository at this point in the history
* fix: change every error line to correct format

* Add color diagnostics during compilation

* Remove unused import

* fix: forgotten newline
  • Loading branch information
dipeshkaphle authored Feb 28, 2022
1 parent 053b138 commit 61e8e10
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
4 changes: 2 additions & 2 deletions player_code/cpp/Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
EXE=run
CXX=g++
FLAGS=-std=c++20 -O2 -static
FLAGS=-std=c++20 -O2 -static -fdiagnostics-color=always

all: $(EXE)

Expand All @@ -14,7 +14,7 @@ main.o: main.cpp player_code.h
$(CXX) $(FLAGS) -c -o main.o main.cpp

$(EXE): $(EXE).o player_code.o main.o
g++ -static -o $(EXE) $(EXE).o player_code.o main.o
g++ -fdiagnostics-color=always -static -o $(EXE) $(EXE).o player_code.o main.o

clean_objects:
rm player_code.o $(EXE).o main.o
Expand Down
12 changes: 10 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,14 @@ pub fn create_error_response(
}
SimulatorError::TimeOutError(e) => ("Timeout Error!".to_owned(), e),
};

let error = error
.lines()
.into_iter()
.map(|x| format!("ERRORS, {}", x))
.collect::<Vec<String>>()
.join("\n");

response::GameStatus {
game_id: game_request.game_id.clone(),
game_status: response::GameStatusEnum::EXECUTE_ERROR,
Expand All @@ -200,8 +208,8 @@ pub fn create_error_response(
coins_used: 0,
has_errors: true,
log: format!(
"ERROR TYPE: {}\n\nERROR LOG\n{}\nERROR TYPE : {}\n",
err_type, error, err_type
"ERRORS, ERROR TYPE: {}\nERRORS, ERROR LOG:\n{}\n",
err_type, error
),
}),
}
Expand Down

0 comments on commit 61e8e10

Please sign in to comment.