Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Small fixes #6

Merged
merged 7 commits into from
Dec 5, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
replace AppError
BB9z committed Dec 2, 2023

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
commit bdb90ba04f9f506761d7a23171ee7c9c45438345
36 changes: 0 additions & 36 deletions App/Model/AppError.swift
Original file line number Diff line number Diff line change
@@ -3,42 +3,6 @@
// App
//

/// App 用错误
enum AppError: LocalizedError {

/// 包含一条信息的错误
case message(_ message: String)

/// Operation is cancelled
case cancel

var errorDescription: String? {
switch self {
case let .message(text):
return text
case .cancel:
return "Operation is cancelled"
}
}

/// Conveniently determine if an object is `AppError.cancel`
static func isCancel(_ err: Error?) -> Bool {
if let err = err as? AppError {
if case .cancel = err {
return true
}
return false
}
if err is CancellationError {
return true
}
if let urlError = err as? URLError {
return urlError.code == .cancelled
}
return false
}
}

enum ModelError: LocalizedError {
/// 模型验证失败
case invalid(String)
1 change: 1 addition & 0 deletions App/Model/CoreData/CDEngine+.swift
Original file line number Diff line number Diff line change
@@ -5,6 +5,7 @@
// Copyright © 2023 B9Software. All rights reserved.
//

import AppFramework
import CoreData

extension CDEngine {
1 change: 1 addition & 0 deletions App/Model/CoreData/CDMessage+.swift
Original file line number Diff line number Diff line change
@@ -5,6 +5,7 @@
// Copyright © 2023 B9Software. All rights reserved.
//

import AppFramework
import CoreData

public extension CDMessage {
1 change: 1 addition & 0 deletions App/Model/Items/Conversation.swift
Original file line number Diff line number Diff line change
@@ -5,6 +5,7 @@
// Copyright © 2023 B9Software. All rights reserved.
//

import AppFramework
import B9Action
import B9MulticastDelegate
import CoreData
1 change: 1 addition & 0 deletions App/Model/Items/Engine.swift
Original file line number Diff line number Diff line change
@@ -5,6 +5,7 @@
// Copyright © 2023 B9Software. All rights reserved.
//

import AppFramework
import CoreData
import Logging

1 change: 1 addition & 0 deletions App/Model/Items/Message.swift
Original file line number Diff line number Diff line change
@@ -5,6 +5,7 @@
// Copyright © 2023 B9Software. All rights reserved.
//

import AppFramework
import B9Action
import B9MulticastDelegate
import CoreData
1 change: 1 addition & 0 deletions App/Model/OpenAI API/OANetwork.swift
Original file line number Diff line number Diff line change
@@ -6,6 +6,7 @@
// Copyright © 2023 B9Software. All rights reserved.
//

import AppFramework
import Foundation

class OANetwork {
3 changes: 2 additions & 1 deletion App/Service/MessageSender.swift
Original file line number Diff line number Diff line change
@@ -5,6 +5,7 @@
// Copyright © 2023 B9Software. All rights reserved.
//

import AppFramework
import CoreData

struct SenderState: Equatable {
@@ -181,7 +182,7 @@ class MessageOperation: Operation {
}

func checkCancel() throws {
if isCancelled { throw AppError.cancel }
if isCancelled { throw CancellationError() }
}

override func cancel() {