Skip to content

Commit e3be77b

Browse files
committed
rc and metadata updates
1 parent b7aa865 commit e3be77b

9 files changed

+36
-45
lines changed

LICENSE

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
The MIT License (MIT)
22

3-
Copyright (c) 2016 Qutheory, LLC
3+
Copyright (c) 2018 Qutheory, LLC
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

Package.swift

+4-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
// swift-tools-version:4.0
2-
32
import PackageDescription
43

54
let package = Package(
@@ -9,16 +8,16 @@ let package = Package(
98
],
109
dependencies: [
1110
// Swift Promises, Futures, and Streams.
12-
.package(url: "https://github.com/vapor/async.git", .exact("1.0.0-beta.1")),
11+
.package(url: "https://github.com/vapor/async.git", from: "1.0.0-rc"),
1312

1413
// Core extensions, type-aliases, and functions that facilitate common tasks.
15-
.package(url: "https://github.com/vapor/core.git", .exact("3.0.0-beta.1")),
14+
.package(url: "https://github.com/vapor/core.git", from: "3.0.0-rc"),
1615

1716
// Non-blocking networking for Swift.
18-
.package(url: "https://github.com/vapor/sockets.git", .exact("3.0.0-beta.1")),
17+
.package(url: "https://github.com/vapor/sockets.git", from: "3.0.0-rc"),
1918

2019
// Core services for creating database integrations.
21-
.package(url: "https://github.com/vapor/database-kit.git", .exact("1.0.0-beta.1")),
20+
.package(url: "https://github.com/vapor/database-kit.git", from: "1.0.0-rc"),
2221
],
2322
targets: [
2423
.target(name: "Redis", dependencies: ["Async", "Bits", "DatabaseKit", "Debugging", "TCP"]),

README.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<p align="center">
2-
<img src="https://cloud.githubusercontent.com/assets/1342803/24753711/a2e633a8-1ad3-11e7-80ee-4b79ebb077cc.png" width="320" alt="Redis">
2+
<img src="https://user-images.githubusercontent.com/1342803/36625644-83750c70-18f1-11e8-9b9a-3bc0a867375c.png" height="64" alt="Redis">
33
<br>
44
<br>
5-
<a href="https://docs.vapor.codes/2.0/redis/package/">
5+
<a href="https://docs.vapor.codes/3.0/">
66
<img src="http://img.shields.io/badge/read_the-docs-92A8D1.svg" alt="Documentation">
77
</a>
88
<a href="http://vapor.team">
@@ -15,6 +15,6 @@
1515
<img src="https://circleci.com/gh/vapor/redis.svg?style=shield" alt="Continuous Integration">
1616
</a>
1717
<a href="https://swift.org">
18-
<img src="http://img.shields.io/badge/swift-3.1-brightgreen.svg" alt="Swift 3.1">
18+
<img src="http://img.shields.io/badge/swift-4.1-brightgreen.svg" alt="Swift 4.1">
1919
</a>
2020
</p>

Sources/Redis/Channel/RedisChannelStream.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ public final class RedisChannelStream: OutputStream {
1717
{
1818
stream = source.stream(to: RedisDataParser().stream(on: worker)).map(to: RedisChannelData.self) { data in
1919
guard let arr = data.array, arr.count == 3 else {
20-
throw RedisError(identifier: "unexpectedResult", reason: "Unexpected result while subscribing: \(data)")
20+
throw RedisError(identifier: "unexpectedResult", reason: "Unexpected result while subscribing: \(data)", source: .capture())
2121
}
2222

2323
return .init(

Sources/Redis/Client/RedisClient+KeyedCache.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ extension RedisClient: KeyedCache {
1414
} else {
1515
switch data.storage {
1616
case .bulkString(let d): entity = try JSONDecoder().decode(D.self, from: d)
17-
default: throw RedisError(identifier: "jsonData", reason: "Data type required to decode JSON.")
17+
default: throw RedisError(identifier: "jsonData", reason: "Data type required to decode JSON.", source: .capture())
1818
}
1919
}
2020
return entity
@@ -34,7 +34,7 @@ extension RedisClient: KeyedCache {
3434
}
3535
switch data.storage {
3636
case .bulkString: break
37-
default: throw RedisError(identifier: "setData", reason: "Set data must be of type bulkString")
37+
default: throw RedisError(identifier: "setData", reason: "Set data must be of type bulkString", source: .capture())
3838
}
3939
return self.command("SET", [RedisData(bulk: key), data]).transform(to: ())
4040
}

Sources/Redis/Data/RedisDataConvertible.swift

+7-7
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ extension String: RedisDataConvertible {
99
/// See `RedisDataConvertible.convertFromRedisData(_:)`
1010
public static func convertFromRedisData(_ data: RedisData) throws -> String {
1111
guard let string = data.string else {
12-
throw RedisError(identifier: "string", reason: "Could not convert to string: \(data)")
12+
throw RedisError(identifier: "string", reason: "Could not convert to string: \(data)", source: .capture())
1313
}
1414
return string
1515
}
@@ -24,7 +24,7 @@ extension FixedWidthInteger {
2424
/// See `RedisDataConvertible.convertFromRedisData(_:)`
2525
public static func convertFromRedisData(_ data: RedisData) throws -> Self {
2626
guard let int = data.int else {
27-
throw RedisError(identifier: "int", reason: "Could not convert to int: \(data)")
27+
throw RedisError(identifier: "int", reason: "Could not convert to int: \(data)", source: .capture())
2828
}
2929
return Self(int)
3030
}
@@ -50,11 +50,11 @@ extension Double {
5050
/// See `RedisDataConvertible.convertFromRedisData(_:)`
5151
public static func convertFromRedisData(_ data: RedisData) throws -> Double {
5252
guard let string = data.string else {
53-
throw RedisError(identifier: "string", reason: "Could not convert to string: \(data)")
53+
throw RedisError(identifier: "string", reason: "Could not convert to string: \(data)", source: .capture())
5454
}
5555

5656
guard let float = Double(string) else {
57-
throw RedisError(identifier: "dobule", reason: "Could not convert to double: \(data)")
57+
throw RedisError(identifier: "dobule", reason: "Could not convert to double: \(data)", source: .capture())
5858
}
5959

6060
return float
@@ -70,11 +70,11 @@ extension Float {
7070
/// See `RedisDataConvertible.convertFromRedisData(_:)`
7171
public static func convertFromRedisData(_ data: RedisData) throws -> Float {
7272
guard let string = data.string else {
73-
throw RedisError(identifier: "string", reason: "Could not convert to string: \(data)")
73+
throw RedisError(identifier: "string", reason: "Could not convert to string: \(data)", source: .capture())
7474
}
7575

7676
guard let float = Float(string) else {
77-
throw RedisError(identifier: "float", reason: "Could not convert to float: \(data)")
77+
throw RedisError(identifier: "float", reason: "Could not convert to float: \(data)", source: .capture())
7878
}
7979

8080
return float
@@ -90,7 +90,7 @@ extension Data {
9090
/// See `RedisDataConvertible.convertFromRedisData(_:)`
9191
public static func convertFromRedisData(_ data: RedisData) throws -> Data {
9292
guard let d = data.data else {
93-
throw RedisError(identifier: "data", reason: "Could not convert to data: \(data)")
93+
throw RedisError(identifier: "data", reason: "Could not convert to data: \(data)", source: .capture())
9494
}
9595
return d
9696
}

Sources/Redis/Data/RedisDataParser.swift

+13-13
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ internal final class RedisDataParser: ByteParser {
2626

2727
if try continueParsing(partial: &value, from: buffer, at: &offset) {
2828
guard case .parsed(let value) = value else {
29-
throw RedisError(identifier: "parse", reason: "Unexpected error while parsing RedisData.")
29+
throw RedisError(identifier: "parse", reason: "Unexpected error while parsing RedisData.", source: .capture())
3030
}
3131

3232
return Future(.completed(consuming: offset, result: value))
@@ -76,7 +76,7 @@ internal final class RedisDataParser: ByteParser {
7676

7777
// Instantiate the integer
7878
guard let number = Int(string) else {
79-
throw RedisError(identifier: "parse", reason: "Unexpected error while parsing RedisData.")
79+
throw RedisError(identifier: "parse", reason: "Unexpected error while parsing RedisData.", source: .capture())
8080
}
8181

8282
return number
@@ -91,29 +91,29 @@ internal final class RedisDataParser: ByteParser {
9191
case .plus:
9292
// Simple string
9393
guard let string = simpleString(from: input, at: &position) else {
94-
throw RedisError(identifier: "parse", reason: "Unexpected error while parsing RedisData.")
94+
throw RedisError(identifier: "parse", reason: "Unexpected error while parsing RedisData.", source: .capture())
9595
}
9696

9797
return .parsed(.basicString(string))
9898
case .hyphen:
9999
// Error
100100
guard let string = simpleString(from: input, at: &position) else {
101-
throw RedisError(identifier: "parse", reason: "Unexpected error while parsing RedisData.")
101+
throw RedisError(identifier: "parse", reason: "Unexpected error while parsing RedisData.", source: .capture())
102102
}
103103

104-
let error = RedisError(identifier: "serverSide", reason: string)
104+
let error = RedisError(identifier: "serverSide", reason: string, source: .capture())
105105
return .parsed(.error(error))
106106
case .colon:
107107
// Integer
108108
guard let number = try integer(from: input, at: &position) else {
109-
throw RedisError(identifier: "parse", reason: "Unexpected error while parsing RedisData.")
109+
throw RedisError(identifier: "parse", reason: "Unexpected error while parsing RedisData.", source: .capture())
110110
}
111111

112112
return .parsed(.integer(number))
113113
case .dollar:
114114
// Bulk strings start with their length
115115
guard let size = try integer(from: input, at: &position) else {
116-
throw RedisError(identifier: "parse", reason: "Unexpected error while parsing RedisData.")
116+
throw RedisError(identifier: "parse", reason: "Unexpected error while parsing RedisData.", source: .capture())
117117
}
118118

119119
// Negative bulk strings are `null`
@@ -126,7 +126,7 @@ internal final class RedisDataParser: ByteParser {
126126
size > -1,
127127
size < input.distance(from: position, to: input.endIndex)
128128
else {
129-
throw RedisError(identifier: "parse", reason: "Unexpected error while parsing RedisData.")
129+
throw RedisError(identifier: "parse", reason: "Unexpected error while parsing RedisData.", source: .capture())
130130
}
131131

132132
let endPosition = input.index(position, offsetBy: size)
@@ -139,11 +139,11 @@ internal final class RedisDataParser: ByteParser {
139139
case .asterisk:
140140
// Arrays start with their element count
141141
guard let size = try integer(from: input, at: &position) else {
142-
throw RedisError(identifier: "parse", reason: "Unexpected error while parsing RedisData.")
142+
throw RedisError(identifier: "parse", reason: "Unexpected error while parsing RedisData.", source: .capture())
143143
}
144144

145145
guard size >= 0 else {
146-
throw RedisError(identifier: "parse", reason: "Unexpected error while parsing RedisData.")
146+
throw RedisError(identifier: "parse", reason: "Unexpected error while parsing RedisData.", source: .capture())
147147
}
148148

149149
var array = [PartialRedisData](repeating: .notYetParsed, count: size)
@@ -165,7 +165,7 @@ internal final class RedisDataParser: ByteParser {
165165

166166
let values = try array.map { value -> RedisData in
167167
guard case .parsed(let value) = value else {
168-
throw RedisError(identifier: "parse", reason: "Unexpected error while parsing RedisData.")
168+
throw RedisError(identifier: "parse", reason: "Unexpected error while parsing RedisData.", source: .capture())
169169
}
170170

171171
return value
@@ -174,7 +174,7 @@ internal final class RedisDataParser: ByteParser {
174174
// All elements have been parsed, return the complete array
175175
return .parsed(.array(values))
176176
default:
177-
throw RedisError(identifier: "invalidTypeToken", reason: "Unexpected error while parsing RedisData.")
177+
throw RedisError(identifier: "invalidTypeToken", reason: "Unexpected error while parsing RedisData.", source: .capture())
178178
}
179179
}
180180

@@ -207,7 +207,7 @@ internal final class RedisDataParser: ByteParser {
207207

208208
let values = try values.map { value -> RedisData in
209209
guard case .parsed(let value) = value else {
210-
throw RedisError(identifier: "parse", reason: "Unexpected error while parsing RedisData.")
210+
throw RedisError(identifier: "parse", reason: "Unexpected error while parsing RedisData.", source: .capture())
211211
}
212212

213213
return value

Sources/Redis/RedisError.swift

+4-13
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,11 @@ import Debugging
22
import COperatingSystem
33

44
/// Errors that can be thrown while working with Redis.
5-
public struct RedisError: Traceable, Debuggable, Helpable, Swift.Error, Encodable {
5+
public struct RedisError: Debuggable {
66
public static let readableName = "Redis Error"
77
public let identifier: String
88
public var reason: String
9-
public var file: String
10-
public var function: String
11-
public var line: UInt
12-
public var column: UInt
9+
public var sourceLocation: SourceLocation?
1310
public var stackTrace: [String]
1411
public var possibleCauses: [String]
1512
public var suggestedFixes: [String]
@@ -20,17 +17,11 @@ public struct RedisError: Traceable, Debuggable, Helpable, Swift.Error, Encodabl
2017
reason: String,
2118
possibleCauses: [String] = [],
2219
suggestedFixes: [String] = [],
23-
file: String = #file,
24-
function: String = #function,
25-
line: UInt = #line,
26-
column: UInt = #column
20+
source: SourceLocation
2721
) {
2822
self.identifier = identifier
2923
self.reason = reason
30-
self.file = file
31-
self.function = function
32-
self.line = line
33-
self.column = column
24+
self.sourceLocation = source
3425
self.stackTrace = RedisError.makeStackTrace()
3526
self.possibleCauses = possibleCauses
3627
self.suggestedFixes = suggestedFixes

circle.yml

+1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ jobs:
1616
- checkout
1717
- run: swift build
1818
- run: swift test
19+
- run: swift build -c release
1920
workflows:
2021
version: 2
2122
tests:

0 commit comments

Comments
 (0)