Skip to content

Commit da2a56e

Browse files
committed
Log tmc-langs error messages
1 parent 1d29f05 commit da2a56e

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

lib/tmc_langs.rb

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ def find_exercise_dirs(path)
3535
def scan_exercise(path)
3636
temp_file = ::Tempfile.new('langs')
3737
clean(path)
38-
exec("scan-exercise", path, temp_file.path)
38+
exec('scan-exercise', path, temp_file.path)
3939
clean(path)
4040
JSON.parse(File.read(temp_file))
4141
end
@@ -45,27 +45,36 @@ def get_test_case_methods(exercise_path)
4545
end
4646

4747
def make_stubs(from_dir, to_dir)
48-
exec("prepare-stubs", from_dir, to_dir)
48+
exec('prepare-stubs', from_dir, to_dir)
4949
end
5050

5151
def make_solutions(from_dir, to_dir)
52-
exec("prepare-solutions", from_dir, to_dir)
52+
exec('prepare-solutions', from_dir, to_dir)
5353
end
5454

5555
def clean(project)
56-
exec("clean", project, "ignored")
56+
exec('clean', project, 'ignored')
5757
end
5858

5959
def get_exercise_config(from_dir)
6060
temp_file = ::Tempfile.new('langs')
61-
exec("get-exercise-packaging-configuration", from_dir, temp_file.path)
61+
exec('get-exercise-packaging-configuration', from_dir, temp_file.path)
6262
JSON.parse(File.read(temp_file))
6363
end
6464

6565
private
66+
6667
def exec(cmd, exercise_path, output_path)
6768
res = SystemCommands.sh!('java', '-jar', jar_path, cmd, '--exercisePath', exercise_path, '--outputPath', output_path)
6869
Rails.logger.debug(res)
6970
res
71+
rescue StandardError => e
72+
begin
73+
langs_output = File.read(output_path)
74+
Rails.logger.error("Executing tmc-langs failed! Tmc-langs output: #{langs_output}")
75+
rescue StandardError => e
76+
Rails.logger.error("Could not read tmc-langs results: #{e} ")
77+
end
78+
raise e
7079
end
7180
end

0 commit comments

Comments
 (0)