Mercurial > hg > orthanc
comparison Plugins/Engine/OrthancPluginDatabase.cpp @ 1651:2e692c83e2f3
improved custom error login
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Fri, 25 Sep 2015 17:29:39 +0200 |
parents | da799f767e5d |
children | de1413733c97 |
comparison
equal
deleted
inserted
replaced
1650:9f34ebfaf2c9 | 1651:2e692c83e2f3 |
---|---|
192 } | 192 } |
193 } | 193 } |
194 | 194 |
195 | 195 |
196 OrthancPluginDatabase::OrthancPluginDatabase(SharedLibrary& library, | 196 OrthancPluginDatabase::OrthancPluginDatabase(SharedLibrary& library, |
197 PluginsErrorDictionary& errorDictionary, | |
197 const OrthancPluginDatabaseBackend& backend, | 198 const OrthancPluginDatabaseBackend& backend, |
198 const OrthancPluginDatabaseExtensions* extensions, | 199 const OrthancPluginDatabaseExtensions* extensions, |
199 size_t extensionsSize, | 200 size_t extensionsSize, |
200 void *payload) : | 201 void *payload) : |
201 library_(library), | 202 library_(library), |
203 errorDictionary_(errorDictionary), | |
202 type_(_OrthancPluginDatabaseAnswerType_None), | 204 type_(_OrthancPluginDatabaseAnswerType_None), |
203 backend_(backend), | 205 backend_(backend), |
204 payload_(payload), | 206 payload_(payload), |
205 listener_(NULL), | 207 listener_(NULL), |
206 answerDicomMap_(NULL), | 208 answerDicomMap_(NULL), |
234 | 236 |
235 OrthancPluginErrorCode error = backend_.addAttachment(payload_, id, &tmp); | 237 OrthancPluginErrorCode error = backend_.addAttachment(payload_, id, &tmp); |
236 | 238 |
237 if (error != OrthancPluginErrorCode_Success) | 239 if (error != OrthancPluginErrorCode_Success) |
238 { | 240 { |
241 errorDictionary_.LogError(error, true); | |
239 throw OrthancException(static_cast<ErrorCode>(error)); | 242 throw OrthancException(static_cast<ErrorCode>(error)); |
240 } | 243 } |
241 } | 244 } |
242 | 245 |
243 | 246 |
246 { | 249 { |
247 OrthancPluginErrorCode error = backend_.attachChild(payload_, parent, child); | 250 OrthancPluginErrorCode error = backend_.attachChild(payload_, parent, child); |
248 | 251 |
249 if (error != OrthancPluginErrorCode_Success) | 252 if (error != OrthancPluginErrorCode_Success) |
250 { | 253 { |
254 errorDictionary_.LogError(error, true); | |
251 throw OrthancException(static_cast<ErrorCode>(error)); | 255 throw OrthancException(static_cast<ErrorCode>(error)); |
252 } | 256 } |
253 } | 257 } |
254 | 258 |
255 | 259 |
257 { | 261 { |
258 OrthancPluginErrorCode error = backend_.clearChanges(payload_); | 262 OrthancPluginErrorCode error = backend_.clearChanges(payload_); |
259 | 263 |
260 if (error != OrthancPluginErrorCode_Success) | 264 if (error != OrthancPluginErrorCode_Success) |
261 { | 265 { |
266 errorDictionary_.LogError(error, true); | |
262 throw OrthancException(static_cast<ErrorCode>(error)); | 267 throw OrthancException(static_cast<ErrorCode>(error)); |
263 } | 268 } |
264 } | 269 } |
265 | 270 |
266 | 271 |
268 { | 273 { |
269 OrthancPluginErrorCode error = backend_.clearExportedResources(payload_); | 274 OrthancPluginErrorCode error = backend_.clearExportedResources(payload_); |
270 | 275 |
271 if (error != OrthancPluginErrorCode_Success) | 276 if (error != OrthancPluginErrorCode_Success) |
272 { | 277 { |
278 errorDictionary_.LogError(error, true); | |
273 throw OrthancException(static_cast<ErrorCode>(error)); | 279 throw OrthancException(static_cast<ErrorCode>(error)); |
274 } | 280 } |
275 } | 281 } |
276 | 282 |
277 | 283 |
282 | 288 |
283 OrthancPluginErrorCode error = backend_.createResource(&id, payload_, publicId.c_str(), Convert(type)); | 289 OrthancPluginErrorCode error = backend_.createResource(&id, payload_, publicId.c_str(), Convert(type)); |
284 | 290 |
285 if (error != OrthancPluginErrorCode_Success) | 291 if (error != OrthancPluginErrorCode_Success) |
286 { | 292 { |
293 errorDictionary_.LogError(error, true); | |
287 throw OrthancException(static_cast<ErrorCode>(error)); | 294 throw OrthancException(static_cast<ErrorCode>(error)); |
288 } | 295 } |
289 | 296 |
290 return id; | 297 return id; |
291 } | 298 } |
296 { | 303 { |
297 OrthancPluginErrorCode error = backend_.deleteAttachment(payload_, id, static_cast<int32_t>(attachment)); | 304 OrthancPluginErrorCode error = backend_.deleteAttachment(payload_, id, static_cast<int32_t>(attachment)); |
298 | 305 |
299 if (error != OrthancPluginErrorCode_Success) | 306 if (error != OrthancPluginErrorCode_Success) |
300 { | 307 { |
308 errorDictionary_.LogError(error, true); | |
301 throw OrthancException(static_cast<ErrorCode>(error)); | 309 throw OrthancException(static_cast<ErrorCode>(error)); |
302 } | 310 } |
303 } | 311 } |
304 | 312 |
305 | 313 |
308 { | 316 { |
309 OrthancPluginErrorCode error = backend_.deleteMetadata(payload_, id, static_cast<int32_t>(type)); | 317 OrthancPluginErrorCode error = backend_.deleteMetadata(payload_, id, static_cast<int32_t>(type)); |
310 | 318 |
311 if (error != OrthancPluginErrorCode_Success) | 319 if (error != OrthancPluginErrorCode_Success) |
312 { | 320 { |
321 errorDictionary_.LogError(error, true); | |
313 throw OrthancException(static_cast<ErrorCode>(error)); | 322 throw OrthancException(static_cast<ErrorCode>(error)); |
314 } | 323 } |
315 } | 324 } |
316 | 325 |
317 | 326 |
319 { | 328 { |
320 OrthancPluginErrorCode error = backend_.deleteResource(payload_, id); | 329 OrthancPluginErrorCode error = backend_.deleteResource(payload_, id); |
321 | 330 |
322 if (error != OrthancPluginErrorCode_Success) | 331 if (error != OrthancPluginErrorCode_Success) |
323 { | 332 { |
333 errorDictionary_.LogError(error, true); | |
324 throw OrthancException(static_cast<ErrorCode>(error)); | 334 throw OrthancException(static_cast<ErrorCode>(error)); |
325 } | 335 } |
326 } | 336 } |
327 | 337 |
328 | 338 |
355 | 365 |
356 OrthancPluginErrorCode error = backend_.getAllPublicIds(GetContext(), payload_, Convert(resourceType)); | 366 OrthancPluginErrorCode error = backend_.getAllPublicIds(GetContext(), payload_, Convert(resourceType)); |
357 | 367 |
358 if (error != OrthancPluginErrorCode_Success) | 368 if (error != OrthancPluginErrorCode_Success) |
359 { | 369 { |
370 errorDictionary_.LogError(error, true); | |
360 throw OrthancException(static_cast<ErrorCode>(error)); | 371 throw OrthancException(static_cast<ErrorCode>(error)); |
361 } | 372 } |
362 | 373 |
363 ForwardAnswers(target); | 374 ForwardAnswers(target); |
364 } | 375 } |
377 OrthancPluginErrorCode error = extensions_.getAllPublicIdsWithLimit | 388 OrthancPluginErrorCode error = extensions_.getAllPublicIdsWithLimit |
378 (GetContext(), payload_, Convert(resourceType), since, limit); | 389 (GetContext(), payload_, Convert(resourceType), since, limit); |
379 | 390 |
380 if (error != OrthancPluginErrorCode_Success) | 391 if (error != OrthancPluginErrorCode_Success) |
381 { | 392 { |
393 errorDictionary_.LogError(error, true); | |
382 throw OrthancException(static_cast<ErrorCode>(error)); | 394 throw OrthancException(static_cast<ErrorCode>(error)); |
383 } | 395 } |
384 | 396 |
385 ForwardAnswers(target); | 397 ForwardAnswers(target); |
386 } | 398 } |
430 | 442 |
431 OrthancPluginErrorCode error = backend_.getChanges(GetContext(), payload_, since, maxResults); | 443 OrthancPluginErrorCode error = backend_.getChanges(GetContext(), payload_, since, maxResults); |
432 | 444 |
433 if (error != OrthancPluginErrorCode_Success) | 445 if (error != OrthancPluginErrorCode_Success) |
434 { | 446 { |
447 errorDictionary_.LogError(error, true); | |
435 throw OrthancException(static_cast<ErrorCode>(error)); | 448 throw OrthancException(static_cast<ErrorCode>(error)); |
436 } | 449 } |
437 } | 450 } |
438 | 451 |
439 | 452 |
444 | 457 |
445 OrthancPluginErrorCode error = backend_.getChildrenInternalId(GetContext(), payload_, id); | 458 OrthancPluginErrorCode error = backend_.getChildrenInternalId(GetContext(), payload_, id); |
446 | 459 |
447 if (error != OrthancPluginErrorCode_Success) | 460 if (error != OrthancPluginErrorCode_Success) |
448 { | 461 { |
462 errorDictionary_.LogError(error, true); | |
449 throw OrthancException(static_cast<ErrorCode>(error)); | 463 throw OrthancException(static_cast<ErrorCode>(error)); |
450 } | 464 } |
451 | 465 |
452 ForwardAnswers(target); | 466 ForwardAnswers(target); |
453 } | 467 } |
460 | 474 |
461 OrthancPluginErrorCode error = backend_.getChildrenPublicId(GetContext(), payload_, id); | 475 OrthancPluginErrorCode error = backend_.getChildrenPublicId(GetContext(), payload_, id); |
462 | 476 |
463 if (error != OrthancPluginErrorCode_Success) | 477 if (error != OrthancPluginErrorCode_Success) |
464 { | 478 { |
479 errorDictionary_.LogError(error, true); | |
465 throw OrthancException(static_cast<ErrorCode>(error)); | 480 throw OrthancException(static_cast<ErrorCode>(error)); |
466 } | 481 } |
467 | 482 |
468 ForwardAnswers(target); | 483 ForwardAnswers(target); |
469 } | 484 } |
481 | 496 |
482 OrthancPluginErrorCode error = backend_.getExportedResources(GetContext(), payload_, since, maxResults); | 497 OrthancPluginErrorCode error = backend_.getExportedResources(GetContext(), payload_, since, maxResults); |
483 | 498 |
484 if (error != OrthancPluginErrorCode_Success) | 499 if (error != OrthancPluginErrorCode_Success) |
485 { | 500 { |
501 errorDictionary_.LogError(error, true); | |
486 throw OrthancException(static_cast<ErrorCode>(error)); | 502 throw OrthancException(static_cast<ErrorCode>(error)); |
487 } | 503 } |
488 } | 504 } |
489 | 505 |
490 | 506 |
498 | 514 |
499 OrthancPluginErrorCode error = backend_.getLastChange(GetContext(), payload_); | 515 OrthancPluginErrorCode error = backend_.getLastChange(GetContext(), payload_); |
500 | 516 |
501 if (error != OrthancPluginErrorCode_Success) | 517 if (error != OrthancPluginErrorCode_Success) |
502 { | 518 { |
519 errorDictionary_.LogError(error, true); | |
503 throw OrthancException(static_cast<ErrorCode>(error)); | 520 throw OrthancException(static_cast<ErrorCode>(error)); |
504 } | 521 } |
505 } | 522 } |
506 | 523 |
507 | 524 |
515 | 532 |
516 OrthancPluginErrorCode error = backend_.getLastExportedResource(GetContext(), payload_); | 533 OrthancPluginErrorCode error = backend_.getLastExportedResource(GetContext(), payload_); |
517 | 534 |
518 if (error != OrthancPluginErrorCode_Success) | 535 if (error != OrthancPluginErrorCode_Success) |
519 { | 536 { |
537 errorDictionary_.LogError(error, true); | |
520 throw OrthancException(static_cast<ErrorCode>(error)); | 538 throw OrthancException(static_cast<ErrorCode>(error)); |
521 } | 539 } |
522 } | 540 } |
523 | 541 |
524 | 542 |
530 | 548 |
531 OrthancPluginErrorCode error = backend_.getMainDicomTags(GetContext(), payload_, id); | 549 OrthancPluginErrorCode error = backend_.getMainDicomTags(GetContext(), payload_, id); |
532 | 550 |
533 if (error != OrthancPluginErrorCode_Success) | 551 if (error != OrthancPluginErrorCode_Success) |
534 { | 552 { |
553 errorDictionary_.LogError(error, true); | |
535 throw OrthancException(static_cast<ErrorCode>(error)); | 554 throw OrthancException(static_cast<ErrorCode>(error)); |
536 } | 555 } |
537 } | 556 } |
538 | 557 |
539 | 558 |
544 | 563 |
545 OrthancPluginErrorCode error = backend_.getPublicId(GetContext(), payload_, resourceId); | 564 OrthancPluginErrorCode error = backend_.getPublicId(GetContext(), payload_, resourceId); |
546 | 565 |
547 if (error != OrthancPluginErrorCode_Success) | 566 if (error != OrthancPluginErrorCode_Success) |
548 { | 567 { |
568 errorDictionary_.LogError(error, true); | |
549 throw OrthancException(static_cast<ErrorCode>(error)); | 569 throw OrthancException(static_cast<ErrorCode>(error)); |
550 } | 570 } |
551 | 571 |
552 if (!ForwardSingleAnswer(s)) | 572 if (!ForwardSingleAnswer(s)) |
553 { | 573 { |
564 | 584 |
565 OrthancPluginErrorCode error = backend_.getResourceCount(&count, payload_, Convert(resourceType)); | 585 OrthancPluginErrorCode error = backend_.getResourceCount(&count, payload_, Convert(resourceType)); |
566 | 586 |
567 if (error != OrthancPluginErrorCode_Success) | 587 if (error != OrthancPluginErrorCode_Success) |
568 { | 588 { |
589 errorDictionary_.LogError(error, true); | |
569 throw OrthancException(static_cast<ErrorCode>(error)); | 590 throw OrthancException(static_cast<ErrorCode>(error)); |
570 } | 591 } |
571 | 592 |
572 return count; | 593 return count; |
573 } | 594 } |
579 | 600 |
580 OrthancPluginErrorCode error = backend_.getResourceType(&type, payload_, resourceId); | 601 OrthancPluginErrorCode error = backend_.getResourceType(&type, payload_, resourceId); |
581 | 602 |
582 if (error != OrthancPluginErrorCode_Success) | 603 if (error != OrthancPluginErrorCode_Success) |
583 { | 604 { |
605 errorDictionary_.LogError(error, true); | |
584 throw OrthancException(static_cast<ErrorCode>(error)); | 606 throw OrthancException(static_cast<ErrorCode>(error)); |
585 } | 607 } |
586 | 608 |
587 return Convert(type); | 609 return Convert(type); |
588 } | 610 } |
594 | 616 |
595 OrthancPluginErrorCode error = backend_.getTotalCompressedSize(&size, payload_); | 617 OrthancPluginErrorCode error = backend_.getTotalCompressedSize(&size, payload_); |
596 | 618 |
597 if (error != OrthancPluginErrorCode_Success) | 619 if (error != OrthancPluginErrorCode_Success) |
598 { | 620 { |
621 errorDictionary_.LogError(error, true); | |
599 throw OrthancException(static_cast<ErrorCode>(error)); | 622 throw OrthancException(static_cast<ErrorCode>(error)); |
600 } | 623 } |
601 | 624 |
602 return size; | 625 return size; |
603 } | 626 } |
609 | 632 |
610 OrthancPluginErrorCode error = backend_.getTotalUncompressedSize(&size, payload_); | 633 OrthancPluginErrorCode error = backend_.getTotalUncompressedSize(&size, payload_); |
611 | 634 |
612 if (error != OrthancPluginErrorCode_Success) | 635 if (error != OrthancPluginErrorCode_Success) |
613 { | 636 { |
637 errorDictionary_.LogError(error, true); | |
614 throw OrthancException(static_cast<ErrorCode>(error)); | 638 throw OrthancException(static_cast<ErrorCode>(error)); |
615 } | 639 } |
616 | 640 |
617 return size; | 641 return size; |
618 } | 642 } |
624 | 648 |
625 OrthancPluginErrorCode error = backend_.isExistingResource(&existing, payload_, internalId); | 649 OrthancPluginErrorCode error = backend_.isExistingResource(&existing, payload_, internalId); |
626 | 650 |
627 if (error != OrthancPluginErrorCode_Success) | 651 if (error != OrthancPluginErrorCode_Success) |
628 { | 652 { |
653 errorDictionary_.LogError(error, true); | |
629 throw OrthancException(static_cast<ErrorCode>(error)); | 654 throw OrthancException(static_cast<ErrorCode>(error)); |
630 } | 655 } |
631 | 656 |
632 return (existing != 0); | 657 return (existing != 0); |
633 } | 658 } |
639 | 664 |
640 OrthancPluginErrorCode error = backend_.isProtectedPatient(&isProtected, payload_, internalId); | 665 OrthancPluginErrorCode error = backend_.isProtectedPatient(&isProtected, payload_, internalId); |
641 | 666 |
642 if (error != OrthancPluginErrorCode_Success) | 667 if (error != OrthancPluginErrorCode_Success) |
643 { | 668 { |
669 errorDictionary_.LogError(error, true); | |
644 throw OrthancException(static_cast<ErrorCode>(error)); | 670 throw OrthancException(static_cast<ErrorCode>(error)); |
645 } | 671 } |
646 | 672 |
647 return (isProtected != 0); | 673 return (isProtected != 0); |
648 } | 674 } |
655 | 681 |
656 OrthancPluginErrorCode error = backend_.listAvailableMetadata(GetContext(), payload_, id); | 682 OrthancPluginErrorCode error = backend_.listAvailableMetadata(GetContext(), payload_, id); |
657 | 683 |
658 if (error != OrthancPluginErrorCode_Success) | 684 if (error != OrthancPluginErrorCode_Success) |
659 { | 685 { |
686 errorDictionary_.LogError(error, true); | |
660 throw OrthancException(static_cast<ErrorCode>(error)); | 687 throw OrthancException(static_cast<ErrorCode>(error)); |
661 } | 688 } |
662 | 689 |
663 if (type_ != _OrthancPluginDatabaseAnswerType_None && | 690 if (type_ != _OrthancPluginDatabaseAnswerType_None && |
664 type_ != _OrthancPluginDatabaseAnswerType_Int32) | 691 type_ != _OrthancPluginDatabaseAnswerType_Int32) |
686 | 713 |
687 OrthancPluginErrorCode error = backend_.listAvailableAttachments(GetContext(), payload_, id); | 714 OrthancPluginErrorCode error = backend_.listAvailableAttachments(GetContext(), payload_, id); |
688 | 715 |
689 if (error != OrthancPluginErrorCode_Success) | 716 if (error != OrthancPluginErrorCode_Success) |
690 { | 717 { |
718 errorDictionary_.LogError(error, true); | |
691 throw OrthancException(static_cast<ErrorCode>(error)); | 719 throw OrthancException(static_cast<ErrorCode>(error)); |
692 } | 720 } |
693 | 721 |
694 if (type_ != _OrthancPluginDatabaseAnswerType_None && | 722 if (type_ != _OrthancPluginDatabaseAnswerType_None && |
695 type_ != _OrthancPluginDatabaseAnswerType_Int32) | 723 type_ != _OrthancPluginDatabaseAnswerType_Int32) |
722 | 750 |
723 OrthancPluginErrorCode error = backend_.logChange(payload_, &tmp); | 751 OrthancPluginErrorCode error = backend_.logChange(payload_, &tmp); |
724 | 752 |
725 if (error != OrthancPluginErrorCode_Success) | 753 if (error != OrthancPluginErrorCode_Success) |
726 { | 754 { |
755 errorDictionary_.LogError(error, true); | |
727 throw OrthancException(static_cast<ErrorCode>(error)); | 756 throw OrthancException(static_cast<ErrorCode>(error)); |
728 } | 757 } |
729 } | 758 } |
730 | 759 |
731 | 760 |
744 | 773 |
745 OrthancPluginErrorCode error = backend_.logExportedResource(payload_, &tmp); | 774 OrthancPluginErrorCode error = backend_.logExportedResource(payload_, &tmp); |
746 | 775 |
747 if (error != OrthancPluginErrorCode_Success) | 776 if (error != OrthancPluginErrorCode_Success) |
748 { | 777 { |
778 errorDictionary_.LogError(error, true); | |
749 throw OrthancException(static_cast<ErrorCode>(error)); | 779 throw OrthancException(static_cast<ErrorCode>(error)); |
750 } | 780 } |
751 } | 781 } |
752 | 782 |
753 | 783 |
760 OrthancPluginErrorCode error = backend_.lookupAttachment | 790 OrthancPluginErrorCode error = backend_.lookupAttachment |
761 (GetContext(), payload_, id, static_cast<int32_t>(contentType)); | 791 (GetContext(), payload_, id, static_cast<int32_t>(contentType)); |
762 | 792 |
763 if (error != OrthancPluginErrorCode_Success) | 793 if (error != OrthancPluginErrorCode_Success) |
764 { | 794 { |
795 errorDictionary_.LogError(error, true); | |
765 throw OrthancException(static_cast<ErrorCode>(error)); | 796 throw OrthancException(static_cast<ErrorCode>(error)); |
766 } | 797 } |
767 | 798 |
768 if (type_ == _OrthancPluginDatabaseAnswerType_None) | 799 if (type_ == _OrthancPluginDatabaseAnswerType_None) |
769 { | 800 { |
790 OrthancPluginErrorCode error = backend_.lookupGlobalProperty | 821 OrthancPluginErrorCode error = backend_.lookupGlobalProperty |
791 (GetContext(), payload_, static_cast<int32_t>(property)); | 822 (GetContext(), payload_, static_cast<int32_t>(property)); |
792 | 823 |
793 if (error != OrthancPluginErrorCode_Success) | 824 if (error != OrthancPluginErrorCode_Success) |
794 { | 825 { |
826 errorDictionary_.LogError(error, true); | |
795 throw OrthancException(static_cast<ErrorCode>(error)); | 827 throw OrthancException(static_cast<ErrorCode>(error)); |
796 } | 828 } |
797 | 829 |
798 return ForwardSingleAnswer(target); | 830 return ForwardSingleAnswer(target); |
799 } | 831 } |
812 | 844 |
813 OrthancPluginErrorCode error = backend_.lookupIdentifier(GetContext(), payload_, &tmp); | 845 OrthancPluginErrorCode error = backend_.lookupIdentifier(GetContext(), payload_, &tmp); |
814 | 846 |
815 if (error != OrthancPluginErrorCode_Success) | 847 if (error != OrthancPluginErrorCode_Success) |
816 { | 848 { |
849 errorDictionary_.LogError(error, true); | |
817 throw OrthancException(static_cast<ErrorCode>(error)); | 850 throw OrthancException(static_cast<ErrorCode>(error)); |
818 } | 851 } |
819 | 852 |
820 ForwardAnswers(target); | 853 ForwardAnswers(target); |
821 } | 854 } |
828 | 861 |
829 OrthancPluginErrorCode error = backend_.lookupIdentifier2(GetContext(), payload_, value.c_str()); | 862 OrthancPluginErrorCode error = backend_.lookupIdentifier2(GetContext(), payload_, value.c_str()); |
830 | 863 |
831 if (error != OrthancPluginErrorCode_Success) | 864 if (error != OrthancPluginErrorCode_Success) |
832 { | 865 { |
866 errorDictionary_.LogError(error, true); | |
833 throw OrthancException(static_cast<ErrorCode>(error)); | 867 throw OrthancException(static_cast<ErrorCode>(error)); |
834 } | 868 } |
835 | 869 |
836 ForwardAnswers(target); | 870 ForwardAnswers(target); |
837 } | 871 } |
845 | 879 |
846 OrthancPluginErrorCode error = backend_.lookupMetadata(GetContext(), payload_, id, static_cast<int32_t>(type)); | 880 OrthancPluginErrorCode error = backend_.lookupMetadata(GetContext(), payload_, id, static_cast<int32_t>(type)); |
847 | 881 |
848 if (error != OrthancPluginErrorCode_Success) | 882 if (error != OrthancPluginErrorCode_Success) |
849 { | 883 { |
884 errorDictionary_.LogError(error, true); | |
850 throw OrthancException(static_cast<ErrorCode>(error)); | 885 throw OrthancException(static_cast<ErrorCode>(error)); |
851 } | 886 } |
852 | 887 |
853 return ForwardSingleAnswer(target); | 888 return ForwardSingleAnswer(target); |
854 } | 889 } |
861 | 896 |
862 OrthancPluginErrorCode error = backend_.lookupParent(GetContext(), payload_, resourceId); | 897 OrthancPluginErrorCode error = backend_.lookupParent(GetContext(), payload_, resourceId); |
863 | 898 |
864 if (error != OrthancPluginErrorCode_Success) | 899 if (error != OrthancPluginErrorCode_Success) |
865 { | 900 { |
901 errorDictionary_.LogError(error, true); | |
866 throw OrthancException(static_cast<ErrorCode>(error)); | 902 throw OrthancException(static_cast<ErrorCode>(error)); |
867 } | 903 } |
868 | 904 |
869 return ForwardSingleAnswer(parentId); | 905 return ForwardSingleAnswer(parentId); |
870 } | 906 } |
878 | 914 |
879 OrthancPluginErrorCode error = backend_.lookupResource(GetContext(), payload_, publicId.c_str()); | 915 OrthancPluginErrorCode error = backend_.lookupResource(GetContext(), payload_, publicId.c_str()); |
880 | 916 |
881 if (error != OrthancPluginErrorCode_Success) | 917 if (error != OrthancPluginErrorCode_Success) |
882 { | 918 { |
919 errorDictionary_.LogError(error, true); | |
883 throw OrthancException(static_cast<ErrorCode>(error)); | 920 throw OrthancException(static_cast<ErrorCode>(error)); |
884 } | 921 } |
885 | 922 |
886 if (type_ == _OrthancPluginDatabaseAnswerType_None) | 923 if (type_ == _OrthancPluginDatabaseAnswerType_None) |
887 { | 924 { |
907 | 944 |
908 OrthancPluginErrorCode error = backend_.selectPatientToRecycle(GetContext(), payload_); | 945 OrthancPluginErrorCode error = backend_.selectPatientToRecycle(GetContext(), payload_); |
909 | 946 |
910 if (error != OrthancPluginErrorCode_Success) | 947 if (error != OrthancPluginErrorCode_Success) |
911 { | 948 { |
949 errorDictionary_.LogError(error, true); | |
912 throw OrthancException(static_cast<ErrorCode>(error)); | 950 throw OrthancException(static_cast<ErrorCode>(error)); |
913 } | 951 } |
914 | 952 |
915 return ForwardSingleAnswer(internalId); | 953 return ForwardSingleAnswer(internalId); |
916 } | 954 } |
923 | 961 |
924 OrthancPluginErrorCode error = backend_.selectPatientToRecycle2(GetContext(), payload_, patientIdToAvoid); | 962 OrthancPluginErrorCode error = backend_.selectPatientToRecycle2(GetContext(), payload_, patientIdToAvoid); |
925 | 963 |
926 if (error != OrthancPluginErrorCode_Success) | 964 if (error != OrthancPluginErrorCode_Success) |
927 { | 965 { |
966 errorDictionary_.LogError(error, true); | |
928 throw OrthancException(static_cast<ErrorCode>(error)); | 967 throw OrthancException(static_cast<ErrorCode>(error)); |
929 } | 968 } |
930 | 969 |
931 return ForwardSingleAnswer(internalId); | 970 return ForwardSingleAnswer(internalId); |
932 } | 971 } |
938 OrthancPluginErrorCode error = backend_.setGlobalProperty | 977 OrthancPluginErrorCode error = backend_.setGlobalProperty |
939 (payload_, static_cast<int32_t>(property), value.c_str()); | 978 (payload_, static_cast<int32_t>(property), value.c_str()); |
940 | 979 |
941 if (error != OrthancPluginErrorCode_Success) | 980 if (error != OrthancPluginErrorCode_Success) |
942 { | 981 { |
982 errorDictionary_.LogError(error, true); | |
943 throw OrthancException(static_cast<ErrorCode>(error)); | 983 throw OrthancException(static_cast<ErrorCode>(error)); |
944 } | 984 } |
945 } | 985 } |
946 | 986 |
947 | 987 |
965 error = backend_.setMainDicomTag(payload_, id, &tmp); | 1005 error = backend_.setMainDicomTag(payload_, id, &tmp); |
966 } | 1006 } |
967 | 1007 |
968 if (error != OrthancPluginErrorCode_Success) | 1008 if (error != OrthancPluginErrorCode_Success) |
969 { | 1009 { |
1010 errorDictionary_.LogError(error, true); | |
970 throw OrthancException(static_cast<ErrorCode>(error)); | 1011 throw OrthancException(static_cast<ErrorCode>(error)); |
971 } | 1012 } |
972 } | 1013 } |
973 | 1014 |
974 | 1015 |
979 OrthancPluginErrorCode error = backend_.setMetadata | 1020 OrthancPluginErrorCode error = backend_.setMetadata |
980 (payload_, id, static_cast<int32_t>(type), value.c_str()); | 1021 (payload_, id, static_cast<int32_t>(type), value.c_str()); |
981 | 1022 |
982 if (error != OrthancPluginErrorCode_Success) | 1023 if (error != OrthancPluginErrorCode_Success) |
983 { | 1024 { |
1025 errorDictionary_.LogError(error, true); | |
984 throw OrthancException(static_cast<ErrorCode>(error)); | 1026 throw OrthancException(static_cast<ErrorCode>(error)); |
985 } | 1027 } |
986 } | 1028 } |
987 | 1029 |
988 | 1030 |
991 { | 1033 { |
992 OrthancPluginErrorCode error = backend_.setProtectedPatient(payload_, internalId, isProtected); | 1034 OrthancPluginErrorCode error = backend_.setProtectedPatient(payload_, internalId, isProtected); |
993 | 1035 |
994 if (error != OrthancPluginErrorCode_Success) | 1036 if (error != OrthancPluginErrorCode_Success) |
995 { | 1037 { |
1038 errorDictionary_.LogError(error, true); | |
996 throw OrthancException(static_cast<ErrorCode>(error)); | 1039 throw OrthancException(static_cast<ErrorCode>(error)); |
997 } | 1040 } |
998 } | 1041 } |
999 | 1042 |
1000 | 1043 |
1001 class OrthancPluginDatabase::Transaction : public SQLite::ITransaction | 1044 class OrthancPluginDatabase::Transaction : public SQLite::ITransaction |
1002 { | 1045 { |
1003 private: | 1046 private: |
1004 const OrthancPluginDatabaseBackend& backend_; | 1047 const OrthancPluginDatabaseBackend& backend_; |
1005 void* payload_; | 1048 void* payload_; |
1049 PluginsErrorDictionary& errorDictionary_; | |
1006 | 1050 |
1007 public: | 1051 public: |
1008 Transaction(const OrthancPluginDatabaseBackend& backend, | 1052 Transaction(const OrthancPluginDatabaseBackend& backend, |
1009 void* payload) : | 1053 void* payload, |
1054 PluginsErrorDictionary& errorDictionary) : | |
1010 backend_(backend), | 1055 backend_(backend), |
1011 payload_(payload) | 1056 payload_(payload), |
1057 errorDictionary_(errorDictionary) | |
1012 { | 1058 { |
1013 } | 1059 } |
1014 | 1060 |
1015 virtual void Begin() | 1061 virtual void Begin() |
1016 { | 1062 { |
1017 OrthancPluginErrorCode error = backend_.startTransaction(payload_); | 1063 OrthancPluginErrorCode error = backend_.startTransaction(payload_); |
1018 | 1064 |
1019 if (error != OrthancPluginErrorCode_Success) | 1065 if (error != OrthancPluginErrorCode_Success) |
1020 { | 1066 { |
1067 errorDictionary_.LogError(error, true); | |
1021 throw OrthancException(static_cast<ErrorCode>(error)); | 1068 throw OrthancException(static_cast<ErrorCode>(error)); |
1022 } | 1069 } |
1023 } | 1070 } |
1024 | 1071 |
1025 virtual void Rollback() | 1072 virtual void Rollback() |
1026 { | 1073 { |
1027 OrthancPluginErrorCode error = backend_.rollbackTransaction(payload_); | 1074 OrthancPluginErrorCode error = backend_.rollbackTransaction(payload_); |
1028 | 1075 |
1029 if (error != OrthancPluginErrorCode_Success) | 1076 if (error != OrthancPluginErrorCode_Success) |
1030 { | 1077 { |
1078 errorDictionary_.LogError(error, true); | |
1031 throw OrthancException(static_cast<ErrorCode>(error)); | 1079 throw OrthancException(static_cast<ErrorCode>(error)); |
1032 } | 1080 } |
1033 } | 1081 } |
1034 | 1082 |
1035 virtual void Commit() | 1083 virtual void Commit() |
1036 { | 1084 { |
1037 OrthancPluginErrorCode error = backend_.commitTransaction(payload_); | 1085 OrthancPluginErrorCode error = backend_.commitTransaction(payload_); |
1038 | 1086 |
1039 if (error != OrthancPluginErrorCode_Success) | 1087 if (error != OrthancPluginErrorCode_Success) |
1040 { | 1088 { |
1089 errorDictionary_.LogError(error, true); | |
1041 throw OrthancException(static_cast<ErrorCode>(error)); | 1090 throw OrthancException(static_cast<ErrorCode>(error)); |
1042 } | 1091 } |
1043 } | 1092 } |
1044 }; | 1093 }; |
1045 | 1094 |
1046 | 1095 |
1047 SQLite::ITransaction* OrthancPluginDatabase::StartTransaction() | 1096 SQLite::ITransaction* OrthancPluginDatabase::StartTransaction() |
1048 { | 1097 { |
1049 return new Transaction(backend_, payload_); | 1098 return new Transaction(backend_, payload_, errorDictionary_); |
1050 } | 1099 } |
1051 | 1100 |
1052 | 1101 |
1053 static void ProcessEvent(IDatabaseListener& listener, | 1102 static void ProcessEvent(IDatabaseListener& listener, |
1054 const _OrthancPluginDatabaseAnswer& answer) | 1103 const _OrthancPluginDatabaseAnswer& answer) |
1091 uint32_t version; | 1140 uint32_t version; |
1092 OrthancPluginErrorCode error = extensions_.getDatabaseVersion(&version, payload_); | 1141 OrthancPluginErrorCode error = extensions_.getDatabaseVersion(&version, payload_); |
1093 | 1142 |
1094 if (error != OrthancPluginErrorCode_Success) | 1143 if (error != OrthancPluginErrorCode_Success) |
1095 { | 1144 { |
1145 errorDictionary_.LogError(error, true); | |
1096 throw OrthancException(static_cast<ErrorCode>(error)); | 1146 throw OrthancException(static_cast<ErrorCode>(error)); |
1097 } | 1147 } |
1098 | 1148 |
1099 return version; | 1149 return version; |
1100 } | 1150 } |
1117 payload_, targetVersion, | 1167 payload_, targetVersion, |
1118 reinterpret_cast<OrthancPluginStorageArea*>(&storageArea)); | 1168 reinterpret_cast<OrthancPluginStorageArea*>(&storageArea)); |
1119 | 1169 |
1120 if (error != OrthancPluginErrorCode_Success) | 1170 if (error != OrthancPluginErrorCode_Success) |
1121 { | 1171 { |
1172 errorDictionary_.LogError(error, true); | |
1122 throw OrthancException(static_cast<ErrorCode>(error)); | 1173 throw OrthancException(static_cast<ErrorCode>(error)); |
1123 } | 1174 } |
1124 } | 1175 } |
1125 } | 1176 } |
1126 | 1177 |