Skip to content
This repository was archived by the owner on Apr 20, 2024. It is now read-only.
This repository was archived by the owner on Apr 20, 2024. It is now read-only.

New error protocol #7

@Casperhr

Description

@Casperhr

enum MyError: AbortError {
case missingUsername(metadata: Node?)
case missingEmail(metadata: Node?)

var code: Int {
    switch self {
        case .missingUsername: return 401
        case .missingEmail: return 402
    }
}

var status: Status {
    return .badRequest
}

var message: String {
    switch self {
        case .missingUsername: return "Missing username"
        case .missingEmail: return "Missing email"
    }
}

var metadata: Node? {
    switch self {
        case missingUsername(metadata: let node): return node
        case missingEmail(metadata: let node): return node
    }
}

}

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions