Skip to content

Commit

Permalink
Merge branch 'master' into bleepbop/VIRTS-2877/objectives-api-v2-pytest
Browse files Browse the repository at this point in the history
  • Loading branch information
bleepbop authored Oct 7, 2021
2 parents 774880d + 2b51007 commit 55367b7
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
10 changes: 9 additions & 1 deletion app/objects/secondclass/c_link.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
from app.objects.secondclass.c_relationship import RelationshipSchema
from app.objects.secondclass.c_visibility import Visibility, VisibilitySchema
from app.utility.base_object import BaseObject
from app.utility.base_parser import PARSER_SIGNALS_FAILURE
from app.utility.base_service import BaseService


Expand Down Expand Up @@ -190,8 +191,15 @@ async def parse(self, operation, result):
source_facts = operation.source.facts if operation else []
try:
relationships = await self._parse_link_result(result, parser, source_facts)

if len(relationships) > 0 and relationships[0] == PARSER_SIGNALS_FAILURE:
logging.getLogger('link').debug(f'link {self.id} (ability id={self.ability.ability_id}) encountered '
f'an error during execution, which was caught during parsing.')
self.status = self.states['ERROR']
relationships = [] # we didn't actually get anything out of this, so let's reset
else:
await self._create_relationships(relationships, operation)
await update_scores(operation, increment=len(relationships), used=self.used, facts=self.facts)
await self._create_relationships(relationships, operation)
except Exception as e:
logging.getLogger('link').debug('error in %s while parsing ability %s: %s'
% (parser.module, self.ability.ability_id, e))
Expand Down
2 changes: 2 additions & 0 deletions app/utility/base_parser.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import json
import re

PARSER_SIGNALS_FAILURE = 418 # Universal Teapot error code


class BaseParser:

Expand Down

0 comments on commit 55367b7

Please sign in to comment.