Skip to content

Commit cd3ef0f

Browse files
committed
added a way to denote errors stemming from loading vs. runtime
1 parent c6d1f79 commit cd3ef0f

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

adk/ADK.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
import os
55
import sys
66
import traceback
7-
87
import six
98

109

@@ -98,9 +97,11 @@ def write_to_pipe(self, payload, pprint=print):
9897
if os.name == "nt":
9998
sys.stdin = payload
10099

101-
def create_exception(self, exception):
100+
def create_exception(self, exception, loading_exception=False):
102101
if hasattr(exception, "error_type"):
103102
error_type = exception.error_type
103+
elif loading_exception:
104+
error_type = "LoadingError"
104105
else:
105106
error_type = "AlgorithmError"
106107
response = json.dumps({
@@ -135,11 +136,10 @@ def process_local(self, local_payload, pprint):
135136
apply_result = self.apply_func(local_payload)
136137
pprint(self.format_response(apply_result))
137138

138-
139139
def init(self, local_payload=None, pprint=print):
140140
self.load()
141141
if self.loading_exception:
142-
load_error = self.create_exception(self.loading_exception)
142+
load_error = self.create_exception(self.loading_exception, loading_exception=True)
143143
self.write_to_pipe(load_error, pprint=pprint)
144144
elif self.is_local and local_payload:
145145
self.process_local(local_payload, pprint)

0 commit comments

Comments
 (0)