Skip to content

Commit 692aa6f

Browse files
ianpartridgeparkera
authored andcommitted
JSONEncoder overlay changes (#1561) (#1661)
1 parent 7b50d79 commit 692aa6f

File tree

3 files changed

+462
-127
lines changed

3 files changed

+462
-127
lines changed

Foundation/Codable.swift

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,22 @@
1+
//===----------------------------------------------------------------------===//
2+
//
13
// This source file is part of the Swift.org open source project
24
//
35
// Copyright (c) 2014 - 2017 Apple Inc. and the Swift project authors
46
// Licensed under Apache License v2.0 with Runtime Library Exception
57
//
6-
// See http://swift.org/LICENSE.txt for license information
7-
// See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
8+
// See https://swift.org/LICENSE.txt for license information
9+
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
810
//
11+
//===----------------------------------------------------------------------===//
12+
13+
//===----------------------------------------------------------------------===//
14+
// Errors
15+
//===----------------------------------------------------------------------===//
16+
17+
// Both of these error types bridge to NSError, and through the entry points they use, no further work is needed to make them localized.
18+
extension EncodingError : LocalizedError {}
19+
extension DecodingError : LocalizedError {}
920

1021
//===----------------------------------------------------------------------===//
1122
// Error Utilities
@@ -39,11 +50,9 @@ internal extension DecodingError {
3950
return "an array"
4051
} else if value is [String : Any] {
4152
return "a dictionary"
42-
} else if value is Bool {
43-
return "a boolean"
4453
} else {
45-
// This should never happen -- we somehow have a non-JSON type here.
46-
preconditionFailure("Invalid storage type \(type(of: value)).")
54+
return "\(type(of: value))"
4755
}
4856
}
4957
}
58+

0 commit comments

Comments
 (0)