Skip to content

Commit 19667cc

Browse files
Merge pull request #650 from nextcloud/enh/noid/logs-on-ocs-exception
log on ocs exception
2 parents a38774b + 4e21f87 commit 19667cc

File tree

2 files changed

+57
-0
lines changed

2 files changed

+57
-0
lines changed

lib/Controller/AdminController.php

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,14 @@ public function create(
150150

151151
return new DataResponse($this->serializeArray($circle));
152152
} catch (Exception $e) {
153+
$this->e(
154+
$e, [
155+
'emulated' => $emulated,
156+
'name' => $name,
157+
'members' => $personal,
158+
'local' => $local
159+
]
160+
);
153161
throw new OcsException($e->getMessage(), $e->getCode());
154162
}
155163
}
@@ -169,6 +177,7 @@ public function destroy(string $emulated, string $circleId): DataResponse {
169177

170178
return new DataResponse($this->serializeArray($circle));
171179
} catch (Exception $e) {
180+
$this->e($e, ['emulated' => $emulated, 'circleId' => $circleId]);
172181
throw new OcsException($e->getMessage(), $e->getCode());
173182
}
174183
}
@@ -202,6 +211,14 @@ public function memberAdd(string $emulated, string $circleId, string $userId, in
202211

203212
return new DataResponse($this->serializeArray($result));
204213
} catch (Exception $e) {
214+
$this->e(
215+
$e, [
216+
'emulated' => $emulated,
217+
'circleId' => $circleId,
218+
'userId' => $userId,
219+
'type' => $type
220+
]
221+
);
205222
throw new OCSException($e->getMessage(), $e->getCode());
206223
}
207224
}
@@ -230,6 +247,15 @@ public function memberLevel(string $emulated, string $circleId, string $memberId
230247

231248
return new DataResponse($this->serializeArray($result));
232249
} catch (Exception $e) {
250+
$this->e(
251+
$e,
252+
[
253+
'emulated' => $emulated,
254+
'circleId' => $circleId,
255+
'memberId' => $memberId,
256+
'level' => $level
257+
]
258+
);
233259
throw new OcsException($e->getMessage(), $e->getCode());
234260
}
235261
}
@@ -247,6 +273,7 @@ public function circles(string $emulated): DataResponse {
247273

248274
return new DataResponse($this->serializeArray($this->circleService->getCircles()));
249275
} catch (Exception $e) {
276+
$this->e($e, ['emulated' => $emulated]);
250277
throw new OCSException($e->getMessage(), $e->getCode());
251278
}
252279
}
@@ -265,6 +292,7 @@ public function circleDetails(string $emulated, string $circleId): DataResponse
265292

266293
return new DataResponse($this->serialize($this->circleService->getCircle($circleId)));
267294
} catch (Exception $e) {
295+
$this->e($e, ['emulated' => $emulated, 'circleId' => $circleId]);
268296
throw new OcsException($e->getMessage(), $e->getCode());
269297
}
270298
}
@@ -284,6 +312,7 @@ public function circleJoin(string $emulated, string $circleId): DataResponse {
284312

285313
return new DataResponse($this->serializeArray($result));
286314
} catch (Exception $e) {
315+
$this->e($e, ['emulated' => $emulated, 'circleId' => $circleId]);
287316
throw new OCSException($e->getMessage(), $e->getCode());
288317
}
289318
}
@@ -303,6 +332,7 @@ public function circleLeave(string $emulated, string $circleId): DataResponse {
303332

304333
return new DataResponse($this->serializeArray($result));
305334
} catch (Exception $e) {
335+
$this->e($e, ['emulated' => $emulated, 'circleId' => $circleId]);
306336
throw new OCSException($e->getMessage(), $e->getCode());
307337
}
308338
}
@@ -328,6 +358,7 @@ public function memberConfirm(string $emulated, string $circleId, string $member
328358

329359
return new DataResponse($this->serializeArray($result));
330360
} catch (Exception $e) {
361+
$this->e($e, ['emulated' => $emulated, 'circleId' => $circleId, 'memberId' => $memberId]);
331362
throw new OCSException($e->getMessage(), $e->getCode());
332363
}
333364
}
@@ -350,6 +381,7 @@ public function memberRemove(string $emulated, string $circleId, string $memberI
350381

351382
return new DataResponse($this->serializeArray($result));
352383
} catch (Exception $e) {
384+
$this->e($e, ['emulated' => $emulated, 'circleId' => $circleId, 'memberId' => $memberId]);
353385
throw new OCSException($e->getMessage(), $e->getCode());
354386
}
355387
}
@@ -368,6 +400,7 @@ public function members(string $emulated, string $circleId): DataResponse {
368400

369401
return new DataResponse($this->serializeArray($this->memberService->getMembers($circleId)));
370402
} catch (Exception $e) {
403+
$this->e($e, ['emulated' => $emulated, 'circleId' => $circleId]);
371404
throw new OCSException($e->getMessage(), $e->getCode());
372405
}
373406
}
@@ -389,6 +422,7 @@ public function editName(string $emulated, string $circleId, string $value): Dat
389422

390423
return new DataResponse($this->serializeArray($outcome));
391424
} catch (Exception $e) {
425+
$this->e($e, ['emulated' => $emulated, 'circleId' => $circleId, 'value' => $value]);
392426
throw new OCSException($e->getMessage(), $e->getCode());
393427
}
394428
}
@@ -410,6 +444,7 @@ public function editDescription(string $emulated, string $circleId, string $valu
410444

411445
return new DataResponse($this->serializeArray($outcome));
412446
} catch (Exception $e) {
447+
$this->e($e, ['emulated' => $emulated, 'circleId' => $circleId, 'value' => $value]);
413448
throw new OCSException($e->getMessage(), $e->getCode());
414449
}
415450
}
@@ -431,6 +466,7 @@ public function editSettings(string $emulated, string $circleId, array $value):
431466

432467
return new DataResponse($this->serializeArray($outcome));
433468
} catch (Exception $e) {
469+
$this->e($e, ['emulated' => $emulated, 'circleId' => $circleId, 'value' => $value]);
434470
throw new OCSException($e->getMessage(), $e->getCode());
435471
}
436472
}
@@ -452,6 +488,7 @@ public function editConfig(string $emulated, string $circleId, int $value): Data
452488

453489
return new DataResponse($this->serializeArray($outcome));
454490
} catch (Exception $e) {
491+
$this->e($e, ['emulated' => $emulated, 'circleId' => $circleId, 'value' => $value]);
455492
throw new OCSException($e->getMessage(), $e->getCode());
456493
}
457494
}
@@ -472,6 +509,7 @@ public function link(string $emulated, string $circleId, string $singleId): Data
472509

473510
return new DataResponse($this->serialize($membership));
474511
} catch (Exception $e) {
512+
$this->e($e, ['emulated' => $emulated, 'circleId' => $circleId, 'singleId' => $singleId]);
475513
throw new OCSException($e->getMessage(), $e->getCode());
476514
}
477515
}

lib/Controller/LocalController.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,7 @@ public function create(string $name, bool $personal = false, bool $local = false
143143

144144
return new DataResponse($this->serializeArray($circle));
145145
} catch (Exception $e) {
146+
$this->e($e, ['name' => $name, 'members' => $personal, 'local' => $local]);
146147
throw new OcsException($e->getMessage(), $e->getCode());
147148
}
148149
}
@@ -163,6 +164,7 @@ public function destroy(string $circleId): DataResponse {
163164

164165
return new DataResponse($this->serializeArray($circle));
165166
} catch (Exception $e) {
167+
$this->e($e, ['circleId' => $circleId]);
166168
throw new OcsException($e->getMessage(), $e->getCode());
167169
}
168170
}
@@ -182,6 +184,7 @@ public function search(string $term): DataResponse {
182184

183185
return new DataResponse($this->serializeArray($this->searchService->search($term)));
184186
} catch (Exception $e) {
187+
$this->e($e, ['term' => $term]);
185188
throw new OcsException($e->getMessage(), $e->getCode());
186189
}
187190
}
@@ -201,6 +204,7 @@ public function circleDetails(string $circleId): DataResponse {
201204

202205
return new DataResponse($this->serialize($this->circleService->getCircle($circleId)));
203206
} catch (Exception $e) {
207+
$this->e($e, ['circleId' => $circleId]);
204208
throw new OcsException($e->getMessage(), $e->getCode());
205209
}
206210
}
@@ -235,6 +239,7 @@ public function memberAdd(string $circleId, string $userId, int $type): DataResp
235239

236240
return new DataResponse($this->serializeArray($result));
237241
} catch (Exception $e) {
242+
$this->e($e, ['circleId' => $circleId, 'userId' => $userId, 'type' => $type]);
238243
throw new OCSException($e->getMessage(), $e->getCode());
239244
}
240245
}
@@ -266,6 +271,7 @@ public function membersAdd(string $circleId, array $members): DataResponse {
266271

267272
return new DataResponse($this->serializeArray($result));
268273
} catch (Exception $e) {
274+
$this->e($e, ['circleId' => $circleId, 'members' => $members]);
269275
throw new OCSException($e->getMessage(), $e->getCode());
270276
}
271277

@@ -283,10 +289,12 @@ public function membersAdd(string $circleId, array $members): DataResponse {
283289
public function circleJoin(string $circleId): DataResponse {
284290
try {
285291
$this->setCurrentFederatedUser();
292+
\OC::$server->getLogger()->log(3, '--- ' . json_encode($circleId));
286293
$result = $this->circleService->circleJoin($circleId);
287294

288295
return new DataResponse($this->serializeArray($result));
289296
} catch (Exception $e) {
297+
$this->e($e, ['circleId' => $circleId]);
290298
throw new OCSException($e->getMessage(), $e->getCode());
291299
}
292300
}
@@ -307,6 +315,7 @@ public function circleLeave(string $circleId): DataResponse {
307315

308316
return new DataResponse($this->serializeArray($result));
309317
} catch (Exception $e) {
318+
$this->e($e, ['circleId' => $circleId]);
310319
throw new OCSException($e->getMessage(), $e->getCode());
311320
}
312321
}
@@ -336,6 +345,7 @@ public function memberLevel(string $circleId, string $memberId, $level): DataRes
336345

337346
return new DataResponse($this->serializeArray($result));
338347
} catch (Exception $e) {
348+
$this->e($e, ['circleId' => $circleId, 'memberId' => $memberId, 'level' => $level]);
339349
throw new OcsException($e->getMessage(), $e->getCode());
340350
}
341351
}
@@ -362,6 +372,7 @@ public function memberConfirm(string $circleId, string $memberId): DataResponse
362372

363373
return new DataResponse($this->serializeArray($result));
364374
} catch (Exception $e) {
375+
$this->e($e, ['circleId' => $circleId, 'memberId' => $memberId]);
365376
throw new OCSException($e->getMessage(), $e->getCode());
366377
}
367378
}
@@ -385,6 +396,7 @@ public function memberRemove(string $circleId, string $memberId): DataResponse {
385396

386397
return new DataResponse($this->serializeArray($result));
387398
} catch (Exception $e) {
399+
$this->e($e, ['circleId' => $circleId, 'memberId' => $memberId]);
388400
throw new OCSException($e->getMessage(), $e->getCode());
389401
}
390402
}
@@ -402,6 +414,7 @@ public function circles(): DataResponse {
402414

403415
return new DataResponse($this->serializeArray($this->circleService->getCircles()));
404416
} catch (Exception $e) {
417+
$this->e($e);
405418
throw new OCSException($e->getMessage(), $e->getCode());
406419
}
407420
}
@@ -421,6 +434,7 @@ public function members(string $circleId): DataResponse {
421434

422435
return new DataResponse($this->serializeArray($this->memberService->getMembers($circleId)));
423436
} catch (Exception $e) {
437+
$this->e($e, ['circleId' => $circleId]);
424438
throw new OCSException($e->getMessage(), $e->getCode());
425439
}
426440
}
@@ -443,6 +457,7 @@ public function editName(string $circleId, string $value): DataResponse {
443457

444458
return new DataResponse($this->serializeArray($outcome));
445459
} catch (Exception $e) {
460+
$this->e($e, ['circleId' => $circleId, 'value' => $value]);
446461
throw new OCSException($e->getMessage(), $e->getCode());
447462
}
448463
}
@@ -465,6 +480,7 @@ public function editDescription(string $circleId, string $value): DataResponse {
465480

466481
return new DataResponse($this->serializeArray($outcome));
467482
} catch (Exception $e) {
483+
$this->e($e, ['circleId' => $circleId, 'value' => $value]);
468484
throw new OCSException($e->getMessage(), $e->getCode());
469485
}
470486
}
@@ -487,6 +503,7 @@ public function editSettings(string $circleId, array $value): DataResponse {
487503

488504
return new DataResponse($this->serializeArray($outcome));
489505
} catch (Exception $e) {
506+
$this->e($e, ['circleId' => $circleId, 'value' => $value]);
490507
throw new OCSException($e->getMessage(), $e->getCode());
491508
}
492509
}
@@ -509,6 +526,7 @@ public function editConfig(string $circleId, int $value): DataResponse {
509526

510527
return new DataResponse($this->serializeArray($outcome));
511528
} catch (Exception $e) {
529+
$this->e($e, ['circleId' => $circleId, 'value' => $value]);
512530
throw new OCSException($e->getMessage(), $e->getCode());
513531
}
514532
}
@@ -530,6 +548,7 @@ public function link(string $circleId, string $singleId): DataResponse {
530548

531549
return new DataResponse($this->serialize($membership));
532550
} catch (Exception $e) {
551+
$this->e($e, ['circleId' => $circleId, 'singleId' => $singleId]);
533552
throw new OCSException($e->getMessage(), $e->getCode());
534553
}
535554
}

0 commit comments

Comments
 (0)