Skip to content

Commit

Permalink
Fixes #10268: technique editor return error 500 and /var/rudder/ncf/5…
Browse files Browse the repository at this point in the history
…0_techniques/ empty
  • Loading branch information
VinceMacBuche committed Feb 24, 2017
1 parent 313489f commit 7b350be
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 6 deletions.
4 changes: 4 additions & 0 deletions builder/css/custom.css
Original file line number Diff line number Diff line change
Expand Up @@ -481,3 +481,7 @@ span.text-fit {
transform: rotate(360deg);
}
}

.ng-toast.ng-toast--right .ng-toast__message {
text-align: left;
}
2 changes: 1 addition & 1 deletion builder/js/ncf.js
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ $scope.capitaliseFirstLetter = function (string) {
function errorNotification (message,details) {
var errorMessage = '<b>An Error occured!</b> ' + message
if (details !== undefined) {
errorMessage += '<br/>Details: ' + details
errorMessage += '<br/><b>Details:</b><pre>' + details +"</pre>"
}
ngToast.create({
content: errorMessage
Expand Down
21 changes: 16 additions & 5 deletions tools/ncf.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,15 @@ class NcfError(Exception):
def __init__(self, message, details="", cause=None):
self.message = message
self.details = details
if cause is not None:
self.details += " caused by : " + cause.message + "\n" + cause.details
# try to get details from inner cause
try:
# Will not add to details if cause is None or message is None
self.details += " caused by : " + cause.message
# Will not add to details if details is None
self.details += "\n" + cause.details
except:
# We got an error while extending error details, just ignore it and keep current value
pass

def __str__(self):
return repr(self.message)
Expand Down Expand Up @@ -80,7 +87,7 @@ def check_output(command, env = {}):
else:
if VERBOSE == 1:
sys.stderr.write("VERBOSE: Exception triggered, Command returned error code " + str(retcode) + "\n")
raise NcfError("Error while running post-hook command " + str(command), error)
raise NcfError("Error while running post-hook command " + " ".join(command), error)

if VERBOSE == 1:
sys.stderr.write("VERBOSE: Command output: '" + output + "'" + "\n")
Expand Down Expand Up @@ -294,7 +301,10 @@ def parse_technique_methods(technique_file):
env = os.environ.copy()
env['RES_OPTIONS'] = 'attempts:0'
out = check_output(["cf-promises", "-pjson", "-f", technique_file], env=env)
promises = json.loads(out)
try:
promises = json.loads(out)
except Exception as e:
raise NcfError("An error occured while parsing technique '"+technique_file+"'", cause = e)

# Sanity check: if more than one bundle, this is a weird file and I'm quitting
bundle_count = 0
Expand Down Expand Up @@ -550,7 +560,8 @@ def get_all_techniques_metadata(include_methods_calls = True, alt_path = ''):
method_calls = parse_technique_methods(file)
all_metadata[metadata['bundle_name']]['method_calls'] = method_calls
except NcfError as e:
error = NcfError("Could not parse Technique file '" + file + "'", cause=e)
bundle_name = os.path.splitext(os.path.basename(file))[0]
error = NcfError("Could not parse Technique '"+ bundle_name+ "'", cause=e)
errors.append(error)
continue # skip this file, it doesn't have the right tags in - yuk!

Expand Down

0 comments on commit 7b350be

Please sign in to comment.