Skip to content

Commit

Permalink
Merge branch 'master' of github.com:SalesforceFoundation/CumulusCI
Browse files Browse the repository at this point in the history
  • Loading branch information
jlantz committed May 22, 2017
2 parents 4023d31 + 5345811 commit ab9922b
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 3 deletions.
8 changes: 8 additions & 0 deletions cumulusci/core/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,3 +114,11 @@ class CommandException(CumulusCIException):
class BrowserTestFailure(CommandException):
""" Raise when browser tests fail """
pass

class ApexCompilationException(CumulusCIException):
""" Raise when apex compilation fails """
pass

class ApexException(CumulusCIException):
""" Raise when an Apex Exception is raised in an org """
pass
20 changes: 17 additions & 3 deletions cumulusci/tasks/anonymous_apex.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import pprint

from cumulusci.tasks.salesforce import BaseSalesforceToolingApiTask
from cumulusci.core.exceptions import ApexCompilationException
from cumulusci.core.exceptions import ApexException
from cumulusci.core.exceptions import SalesforceException


class AnonymousApexTask(BaseSalesforceToolingApiTask):
""" Executes a string of anonymous apex. """
Expand All @@ -23,4 +25,16 @@ def _run_task(self):
path,
result.status_code,
result.content)
self.logger.info(pprint.pprint(result.json()))
# anon_results is an ExecuteAnonymous Result
# https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/sforce_api_calls_executeanonymous_result.htm

anon_results = result.json()
if not anon_results['compiled']:
raise ApexCompilationException(
anon_results['line'], anon_results['compileProblem'])

if not anon_results['success']:
raise ApexException(
anon_results['exceptionMessage'], anon_results['exceptionStackTrace'])

self.logger.info('Anonymous Apex Success')

0 comments on commit ab9922b

Please sign in to comment.