All Questions
Tagged with error-handling swift
495
questions
-2
votes
1
answer
114
views
does throwing an error inside a do block leads to the catch block?
I have a do catch block with a function inside that can throw. In the catch block I throw a specific error. I'm interested in what happens when the function throws so I threw an error instead of the ...
0
votes
0
answers
107
views
Getting non-localized description or key from NSError
Is there any way to get non-localized key or description from the NSError? I need some way to group errors from API requests and send them back for analytics, but it seems all descriptions or keys ...
1
vote
0
answers
380
views
Casting Custom Swift Error Back from Kotlin in KMM?
I am working on a Kotlin Multiplatform Mobile (KMM) project and I have a custom error defined in Swift like so:
enum MyError: Error {
case runtimeError(String)
}
I have a method in Swift which ...
0
votes
0
answers
36
views
Swift Handling Custom Error but something wrong
This is my custom error
public struct CSHttpError: Error {
enum CSHttpErrorScene {
case clientRequestError
case customError
}
let code: Int?
let kind: ...
1
vote
1
answer
296
views
How to throw errors from a setter in Swift?
I wanted to know if there was a way to have setters throw errors in Swift. I assume this would solve my problem but the fact that I couldn't find a way to do it makes me wonder if I've structured my ...
0
votes
0
answers
57
views
While Sending BNB Coin it throws error nodeError(desc: "unknown account") ios swift
function which i used to send bnb
i have current user wallet address from userdefault
receiver user wallet address from textfield
amount from textfield
and i am sending that in options
function which ...
0
votes
0
answers
142
views
Swift coding issue: Type '_ErrorCodeProtocol' has no member 'success'
I'm currently working on a Swift project and I'm encountering some issues with my code. I'm seeking assistance from the community to help me resolve these problems. Any guidance or suggestions would ...
1
vote
2
answers
704
views
Map Publisher to another publishers sequentially and handle errors for each step separately (or skip) in Swift Combine?
Code:
import Combine
func login() -> Future<Token, Error> { ... }
func updateImage() -> Future<Status, Never> { ... }
func getProfile() -> Future<Profile, Error> { ... }
I ...
1
vote
1
answer
137
views
Crash on account creation, error and button code included
I am getting the following error around 20% of the time I try to create an account:
Can someone please help me in diagnosing the issue please
Crashed: com.apple.main-thread
EXC_BAD_ACCESS ...
2
votes
2
answers
198
views
Swift: Result's Failure Type cannot be protocol - "Type 'any ShadowError' cannot conform to Error"
Error is a protocol and one is able to do this...
let x: Result<Void, Error> = .success(())
ShadowError conforms to Error and is also a protocol yet one is not able to do this...
protocol ...
2
votes
1
answer
908
views
cancel Task inside Future (async/await with combine)
I decide to use async/ await with the Combine framework.
I used an extension on the Future class and put a Task block inside it.
It seems OK, and I get a result or error, but I have a problem with ...
1
vote
2
answers
88
views
is it possible to swizzle the keyword `throw`?
I was thinking about error handling and I learned about swizzling recently. Swizzling is certainly a tool which shouldn't be used too often, and I think I understand that, but it made me wonder. If ...
0
votes
1
answer
57
views
How I can fetch codingPath when codable issue happens?
I tried this, but it raise an error:
do {
guard let firstValue = result.values.first else {
completion?(nil, NSError(domain: "MyDomain", code: 1, userInfo: [...
-1
votes
1
answer
560
views
How to print error message while parsing in swift
this is json error structure:
{
"jsonrpc": "2.0",
"error": {
"code": "-32700",
"message": "Parse error",
...
0
votes
1
answer
4k
views
Call must be made on main thread i can get the data but when i want it to show error message it crashes
StartScreenVC
import UIKit
class StartScreenVC: UIViewController {
private var apiService = ApiService()
override func viewDidLoad() {
super.viewDidLoad()
...