Diff
Not logged in

Differences From Artifact [a5c8048813]:

To Artifact [ac0ac00c7c]:


     1      1   // Copyright 2015 MaidSafe.net limited.
     2      2   //
     3      3   // This SAFE Network Software is licensed to you under (1) the MaidSafe.net Commercial License,
     4      4   // version 1.0 or later, or (2) The General Public License (GPL), version 3, depending on which
     5      5   // licence you accepted on initial access to the Software (the "Licences").
     6      6   //
     7      7   // By contributing code to the SAFE Network Software, or to this project generally, you agree to be
     8         -// bound by the terms of the MaidSafe Contributor Agreement, version 1.0.  This, along with the
     9         -// Licenses can be found in the root directory of this project at LICENSE, COPYING and CONTRIBUTOR.
            8  +// bound by the terms of the MaidSafe Contributor Agreement.  This, along with the Licenses can be
            9  +// found in the root directory of this project at LICENSE, COPYING and CONTRIBUTOR.
    10     10   //
    11     11   // Unless required by applicable law or agreed to in writing, the SAFE Network Software distributed
    12     12   // under the GPL Licence is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
    13     13   // KIND, either express or implied.
    14     14   //
    15     15   // Please review the Licences for the specific language governing permissions and limitations
    16     16   // relating to use of the SAFE Network Software.
    17         -
    18     17   
    19     18   use core::SelfEncryptionStorageError;
    20     19   use maidsafe_utilities::serialisation::SerialisationError;
    21     20   use routing::DataIdentifier;
    22     21   use routing::client_errors::{GetError, MutationError};
    23     22   use routing::messaging;
    24     23   use self_encryption::SelfEncryptionError;
................................................................................
   188    187               }
   189    188               CoreError::MutationFailure { reason: MutationError::NetworkFull, .. } => {
   190    189                   CLIENT_ERROR_START_RANGE - 27
   191    190               }
   192    191               CoreError::MutationFailure { reason: MutationError::DataTooLarge, .. } => {
   193    192                   CLIENT_ERROR_START_RANGE - 28
   194    193               }
          194  +            CoreError::MutationFailure { reason: MutationError::InvalidInvitation, .. } => {
          195  +                CLIENT_ERROR_START_RANGE - 29
          196  +            }
          197  +            CoreError::MutationFailure {
          198  +                reason: MutationError::InvitationAlreadyClaimed, ..
          199  +            } => CLIENT_ERROR_START_RANGE - 30,
   195    200               CoreError::SelfEncryption(
   196    201                   SelfEncryptionError::Compression::<SelfEncryptionStorageError>) => {
   197         -                CLIENT_ERROR_START_RANGE - 29
          202  +                CLIENT_ERROR_START_RANGE - 31
   198    203               }
   199    204               CoreError::SelfEncryption(
   200    205                   SelfEncryptionError::Decryption::<SelfEncryptionStorageError>) => {
   201         -                CLIENT_ERROR_START_RANGE - 30
          206  +                CLIENT_ERROR_START_RANGE - 32
   202    207               }
   203    208               CoreError::SelfEncryption(SelfEncryptionError::Io::<SelfEncryptionStorageError>(_)) => {
   204         -                CLIENT_ERROR_START_RANGE - 31
          209  +                CLIENT_ERROR_START_RANGE - 33
   205    210               }
   206    211               CoreError::GetAccountInfoFailure { reason: GetError::NoSuchAccount, .. } => {
   207         -                CLIENT_ERROR_START_RANGE - 32
          212  +                CLIENT_ERROR_START_RANGE - 34
   208    213               }
   209         -            CoreError::GetAccountInfoFailure { .. } => CLIENT_ERROR_START_RANGE - 33,
   210         -            CoreError::RequestTimeout => CLIENT_ERROR_START_RANGE - 34,
          214  +            CoreError::GetAccountInfoFailure { .. } => CLIENT_ERROR_START_RANGE - 35,
          215  +            CoreError::RequestTimeout => CLIENT_ERROR_START_RANGE - 36,
   211    216               CoreError::SelfEncryption(SelfEncryptionError
   212    217                                         ::Storage
   213    218                                         ::<SelfEncryptionStorageError>(
   214    219                                             SelfEncryptionStorageError(err))) => (*err).into(),
   215         -            CoreError::InvalidStructuredDataTypeTag => CLIENT_ERROR_START_RANGE - 35,
          220  +            CoreError::InvalidStructuredDataTypeTag => CLIENT_ERROR_START_RANGE - 37,
   216    221           }
   217    222       }
   218    223   }
   219    224   
   220    225   impl Debug for CoreError {
   221    226       fn fmt(&self, formatter: &mut Formatter) -> fmt::Result {
   222         -        try!(write!(formatter, "{} - ", self.description()));
          227  +        write!(formatter, "{} - ", self.description())?;
   223    228           match *self {
   224    229               CoreError::StructuredDataHeaderSizeProhibitive => {
   225    230                   write!(formatter, "CoreError::StructuredDataHeaderSizeProhibitive")
   226    231               }
   227    232               CoreError::UnsuccessfulEncodeDecode(ref error) => {
   228    233                   write!(formatter,
   229    234                          "CoreError::UnsuccessfulEncodeDecode -> {:?}",
................................................................................
   261    266                   write!(formatter, "CoreError::UnsupportedSaltSizeForPwHash")
   262    267               }
   263    268               CoreError::UnsuccessfulPwHash => write!(formatter, "CoreError::UnsuccessfulPwHash"),
   264    269               CoreError::OperationAborted => write!(formatter, "CoreError::OperationAborted"),
   265    270               CoreError::MpidMessagingError(ref error) => {
   266    271                   write!(formatter, "CoreError::MpidMessagingError -> {:?}", error)
   267    272               }
   268         -            CoreError::GetFailure { ref data_id, ref reason } => {
          273  +            CoreError::GetFailure {
          274  +                ref data_id,
          275  +                ref reason,
          276  +            } => {
   269    277                   write!(formatter,
   270    278                          "CoreError::GetFailure::{{ reason: {:?}, data_id: {:?}}}",
   271    279                          reason,
   272    280                          data_id)
   273    281               }
   274    282               CoreError::GetAccountInfoFailure { ref reason } => {
   275    283                   write!(formatter,
   276    284                          "CoreError::GetAccountInfoFailure::{{ reason: {:?}}}",
   277    285                          reason)
   278    286               }
   279         -            CoreError::MutationFailure { ref data_id, ref reason } => {
          287  +            CoreError::MutationFailure {
          288  +                ref data_id,
          289  +                ref reason,
          290  +            } => {
   280    291                   write!(formatter,
   281    292                          "CoreError::MutationFailure::{{ reason: {:?}, data_id: {:?}}}",
   282    293                          reason,
   283    294                          data_id)
   284    295               }
   285    296               CoreError::SelfEncryption(ref error) => {
   286    297                   write!(formatter, "CoreError::SelfEncryption -> {:?}", error)
................................................................................
   413    424           }
   414    425       }
   415    426   }
   416    427   
   417    428   #[cfg(test)]
   418    429   mod test {
   419    430   
          431  +    use super::*;
   420    432       use core::SelfEncryptionStorageError;
   421    433       use rand;
   422    434       use routing::DataIdentifier;
   423    435       use routing::client_errors::MutationError;
   424    436       use self_encryption::SelfEncryptionError;
   425         -    use super::*;
   426    437   
   427    438       #[test]
   428    439       fn self_encryption_error() {
   429    440           let id = rand::random();
   430    441           let core_err_0 = CoreError::MutationFailure {
   431    442               data_id: DataIdentifier::Structured(id, 10000),
   432    443               reason: MutationError::LowBalance,