Skip to content

Commit 0f51cf8

Browse files
authored
Merge pull request #155 from docusign/fix/display-error-message-in-doc-gen
Add error handling for doc gen example
2 parents b2b3e00 + 90d8a35 commit 0f51cf8

File tree

1 file changed

+20
-15
lines changed

1 file changed

+20
-15
lines changed

src/Controllers/Examples/eSignature/EG042DocumentGeneration.php

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
use DocuSign\Controllers\eSignBaseController;
99
use DocuSign\Services\Examples\eSignature\DocumentGenerationService;
10+
use DocuSign\eSign\Client\ApiException;
1011
use DocuSign\Services\ManifestService;
1112

1213
class EG042DocumentGeneration extends eSignBaseController
@@ -36,22 +37,26 @@ public function createController(): void
3637
{
3738
$this->checkDsToken();
3839

39-
$envelopeId = DocumentGenerationService::worker(
40-
$this->args,
41-
$this->clientService,
42-
self::DEMO_DOCS_PATH
43-
);
44-
45-
if ($envelopeId) {
46-
$this->clientService->showDoneTemplateFromManifest(
47-
$this->codeExampleText,
48-
null,
49-
ManifestService::replacePlaceholders(
50-
"{0}",
51-
$envelopeId,
52-
$this->codeExampleText["ResultsPageText"]
53-
)
40+
try {
41+
$envelopeId = DocumentGenerationService::worker(
42+
$this->args,
43+
$this->clientService,
44+
self::DEMO_DOCS_PATH
5445
);
46+
47+
if ($envelopeId) {
48+
$this->clientService->showDoneTemplateFromManifest(
49+
$this->codeExampleText,
50+
null,
51+
ManifestService::replacePlaceholders(
52+
"{0}",
53+
$envelopeId,
54+
$this->codeExampleText["ResultsPageText"]
55+
)
56+
);
57+
}
58+
} catch (ApiException $e) {
59+
$this->clientService->showErrorTemplate($e);
5560
}
5661
}
5762

0 commit comments

Comments
 (0)