comparison Plugins/Engine/OrthancPlugins.cpp @ 1646:da799f767e5d

simplification in error casting with plugins
author Sebastien Jodogne <s.jodogne@gmail.com>
date Thu, 24 Sep 2015 16:01:09 +0200
parents 939b921b2c81
children 8040d56cb0b3
comparison
equal deleted inserted replaced
1645:1558b3226b18 1646:da799f767e5d
89 OrthancPluginErrorCode error = callbacks_.create 89 OrthancPluginErrorCode error = callbacks_.create
90 (uuid.c_str(), content, size, Plugins::Convert(type)); 90 (uuid.c_str(), content, size, Plugins::Convert(type));
91 91
92 if (error != OrthancPluginErrorCode_Success) 92 if (error != OrthancPluginErrorCode_Success)
93 { 93 {
94 throw OrthancException(Plugins::Convert(error)); 94 throw OrthancException(static_cast<ErrorCode>(error));
95 } 95 }
96 } 96 }
97 97
98 98
99 virtual void Read(std::string& content, 99 virtual void Read(std::string& content,
106 OrthancPluginErrorCode error = callbacks_.read 106 OrthancPluginErrorCode error = callbacks_.read
107 (&buffer, &size, uuid.c_str(), Plugins::Convert(type)); 107 (&buffer, &size, uuid.c_str(), Plugins::Convert(type));
108 108
109 if (error != OrthancPluginErrorCode_Success) 109 if (error != OrthancPluginErrorCode_Success)
110 { 110 {
111 throw OrthancException(Plugins::Convert(error)); 111 throw OrthancException(static_cast<ErrorCode>(error));
112 } 112 }
113 113
114 try 114 try
115 { 115 {
116 content.resize(static_cast<size_t>(size)); 116 content.resize(static_cast<size_t>(size));
136 OrthancPluginErrorCode error = callbacks_.remove 136 OrthancPluginErrorCode error = callbacks_.remove
137 (uuid.c_str(), Plugins::Convert(type)); 137 (uuid.c_str(), Plugins::Convert(type));
138 138
139 if (error != OrthancPluginErrorCode_Success) 139 if (error != OrthancPluginErrorCode_Success)
140 { 140 {
141 throw OrthancException(Plugins::Convert(error)); 141 throw OrthancException(static_cast<ErrorCode>(error));
142 } 142 }
143 } 143 }
144 }; 144 };
145 145
146 146
462 { 462 {
463 return true; 463 return true;
464 } 464 }
465 else 465 else
466 { 466 {
467 throw OrthancException(Plugins::Convert(error)); 467 throw OrthancException(static_cast<ErrorCode>(error));
468 } 468 }
469 } 469 }
470 470
471 471
472 void OrthancPlugins::SignalStoredInstance(const std::string& instanceId, 472 void OrthancPlugins::SignalStoredInstance(const std::string& instanceId,
483 (reinterpret_cast<OrthancPluginDicomInstance*>(&instance), 483 (reinterpret_cast<OrthancPluginDicomInstance*>(&instance),
484 instanceId.c_str()); 484 instanceId.c_str());
485 485
486 if (error != OrthancPluginErrorCode_Success) 486 if (error != OrthancPluginErrorCode_Success)
487 { 487 {
488 throw OrthancException(Plugins::Convert(error)); 488 throw OrthancException(static_cast<ErrorCode>(error));
489 } 489 }
490 } 490 }
491 } 491 }
492 492
493 493
505 Plugins::Convert(change.GetResourceType()), 505 Plugins::Convert(change.GetResourceType()),
506 change.GetPublicId().c_str()); 506 change.GetPublicId().c_str());
507 507
508 if (error != OrthancPluginErrorCode_Success) 508 if (error != OrthancPluginErrorCode_Success)
509 { 509 {
510 throw OrthancException(Plugins::Convert(error)); 510 throw OrthancException(static_cast<ErrorCode>(error));
511 } 511 }
512 } 512 }
513 } 513 }
514 514
515 515