File tree Expand file tree Collapse file tree 1 file changed +8
-9
lines changed Expand file tree Collapse file tree 1 file changed +8
-9
lines changed Original file line number Diff line number Diff line change 99#include " serialize.h"
1010
1111#include < iostream>
12+ #include < stdexcept>
1213#include < stdlib.h>
1314#include < string>
1415
@@ -286,20 +287,18 @@ class CColorAmount : public colorAmount_t
286287
287288 type_Color Color () const
288289 {
289- if (this ->size () == 1 )
290- return this ->begin ()->first ;
291- else
292- return -1 ;
290+ if (this ->size () != 1 )
291+ throw std::runtime_error (" CColorAmount::Color(): The size of color amount should be 1." );
292+ return this ->begin ()->first ;
293293 }
294294
295295 CAmount Value () const
296296 {
297- if (this ->size () == 1 )
298- return this ->begin ()->second ;
299- else if (this ->size () == 0 )
297+ if (this ->size () == 0 )
300298 return 0 ;
301- else
302- return -1 ;
299+ if (this ->size () != 1 )
300+ throw std::runtime_error (" CColorAmount::Value(): The size of color amount should be 0 or 1." );
301+ return this ->begin ()->second ;
303302 }
304303
305304 CAmount TotalValue () const
You can’t perform that action at this time.
0 commit comments