Skip to content

Commit

Permalink
fix(fabricerror): GenericFabricError make name mandatory (#29)
Browse files Browse the repository at this point in the history
  • Loading branch information
portellaa authored Oct 21, 2022
1 parent 478d9d3 commit d38dc37
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 17 deletions.
16 changes: 3 additions & 13 deletions Sources/YData/Core/Error/GenericFabricError.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,32 +4,22 @@ public struct GenericFabricError: FabricError {
public var context: [String: String]?
public var description: String
public var httpCode: Int = 500
internal var _name: String? // swiftlint:disable:this identifier_name
public var name: String
public var returnValue: Int

public var name: String {
get {
_name ?? "\(Self.self)"
}

set {
_name = newValue
}
}

public init(
context: [String: String]? = nil,
description: String,
httpCode: Int? = 500,
name: String? = nil,
name: String = "\(Self.self)",
returnValue: Int
) {
self.context = context
self.description = description
if let httpCode {
self.httpCode = httpCode
}
self._name = name
self.name = name
self.returnValue = returnValue
}
}
2 changes: 1 addition & 1 deletion Sources/YData/Database/DatabaseClient.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ import Foundation

public protocol DatabaseClient {
associatedtype Context: DatabaseClientContext

var context: Context { get }
}
6 changes: 3 additions & 3 deletions Sources/YData/Extensions/String+random.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ import Foundation
public extension String {
static func random(length: Int) -> String {
let letters = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!?+-*/=_#$%&"
var s = ""
var result = ""
for _ in 0 ..< length {
s.append(letters.randomElement()!)
result.append(letters.randomElement()!) // swiftlint:disable:this force_unwrap
}
return s
return result
}
}

0 comments on commit d38dc37

Please sign in to comment.