@@ -87,17 +87,17 @@ public function create(?int $fileId = null, ?string $filePath = null, =string $b
8787 } catch (NotFoundException $ e ) {
8888 return new DataResponse ([], Http::STATUS_NOT_FOUND );
8989 } catch (NotPermittedException $ e ) {
90- return new DataResponse ($ this ->l10n ->t ('This file cannot be displayed as download is disabled by the share ' ), 404 );
90+ return new DataResponse ([ ' error ' => $ this ->l10n ->t ('This file cannot be displayed as download is disabled by the share ' )] , 404 );
9191 }
9292 } elseif ($ fileId ) {
9393 try {
9494 $ file = $ this ->documentService ->getFileById ($ fileId );
9595 } catch (NotFoundException |NotPermittedException $ e ) {
9696 $ this ->logger ->error ('No permission to access this file ' , [ 'exception ' => $ e ]);
97- return new DataResponse ($ this ->l10n ->t ('No permission to access this file. ' ), Http::STATUS_NOT_FOUND );
97+ return new DataResponse ([ ' error ' => $ this ->l10n ->t ('No permission to access this file. ' )] , Http::STATUS_NOT_FOUND );
9898 }
9999 } else {
100- return new DataResponse (' No valid file argument provided ' , Http::STATUS_PRECONDITION_FAILED );
100+ return new DataResponse ([ ' error ' => ' No valid file argument provided '] , Http::STATUS_PRECONDITION_FAILED );
101101 }
102102
103103 $ storage = $ file ->getStorage ();
@@ -108,7 +108,7 @@ public function create(?int $fileId = null, ?string $filePath = null, =string $b
108108 $ share = $ storage ->getShare ();
109109 $ shareAttribtues = $ share ->getAttributes ();
110110 if ($ shareAttribtues !== null && $ shareAttribtues ->getAttribute ('permissions ' , 'download ' ) === false ) {
111- return new DataResponse ($ this ->l10n ->t ('This file cannot be displayed as download is disabled by the share ' ), 403 );
111+ return new DataResponse ([ ' error ' => $ this ->l10n ->t ('This file cannot be displayed as download is disabled by the share ' )] , 403 );
112112 }
113113 }
114114
@@ -118,7 +118,7 @@ public function create(?int $fileId = null, ?string $filePath = null, =string $b
118118 $ document = $ this ->documentService ->getDocument ($ file ->getId ());
119119 $ freshSession = $ document === null ;
120120 if ($ baseVersionEtag && $ baseVersionEtag !== $ document ?->getBaseVersionEtag()) {
121- return new DataResponse ($ this ->l10n ->t ('Editing session has expired. Please reload the page. ' ), Http::STATUS_PRECONDITION_FAILED );
121+ return new DataResponse ([ ' error ' => $ this ->l10n ->t ('Editing session has expired. Please reload the page. ' )] , Http::STATUS_PRECONDITION_FAILED );
122122 }
123123
124124 if ($ freshSession ) {
@@ -134,7 +134,7 @@ public function create(?int $fileId = null, ?string $filePath = null, =string $b
134134 }
135135 } catch (Exception $ e ) {
136136 $ this ->logger ->error ($ e ->getMessage (), ['exception ' => $ e ]);
137- return new DataResponse (' Failed to create the document session ' , 500 );
137+ return new DataResponse ([ ' error ' => ' Failed to create the document session '] , 500 );
138138 }
139139
140140 $ session = $ this ->sessionService ->initSession ($ document ->getId (), $ guestName );
@@ -193,18 +193,18 @@ public function push(Session $session, Document $document, $version, $steps, $aw
193193 $ session = $ this ->sessionService ->updateSessionAwareness ($ session , $ awareness );
194194 } catch (DoesNotExistException $ e ) {
195195 // Session was removed in the meantime. #3875
196- return new DataResponse ($ this ->l10n ->t ('Editing session has expired. Please reload the page. ' ), Http::STATUS_PRECONDITION_FAILED );
196+ return new DataResponse ([ ' error ' => $ this ->l10n ->t ('Editing session has expired. Please reload the page. ' )] , Http::STATUS_PRECONDITION_FAILED );
197197 }
198198 if (empty ($ steps )) {
199199 return new DataResponse ([]);
200200 }
201201 try {
202202 $ result = $ this ->documentService ->addStep ($ document , $ session , $ steps , $ version , $ token );
203203 } catch (InvalidArgumentException $ e ) {
204- return new DataResponse ($ e ->getMessage (), 422 );
204+ return new DataResponse ([ ' error ' => $ e ->getMessage ()] , 422 );
205205 } catch (DoesNotExistException |NotPermittedException ) {
206206 // Either no write access or session was removed in the meantime (#3875).
207- return new DataResponse ($ this ->l10n ->t ('Editing session has expired. Please reload the page. ' ), Http::STATUS_PRECONDITION_FAILED );
207+ return new DataResponse ([ ' error ' => $ this ->l10n ->t ('Editing session has expired. Please reload the page. ' )] , Http::STATUS_PRECONDITION_FAILED );
208208 }
209209 return new DataResponse ($ result );
210210 }
0 commit comments