Skip to content

Commit

Permalink
Add more context to malformed JSON errors (#429)
Browse files Browse the repository at this point in the history
Include the JSON text and underlying error.
  • Loading branch information
neonichu authored Aug 25, 2023
1 parent c110bd1 commit 5446eab
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions Sources/TSCBasic/JSON.swift
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ import Foundation

enum JSONDecodingError: Error {
/// The input byte string is malformed.
case malformed
case malformed(json: String, underlyingError: Error)
}

extension JSONDecodingError: CustomNSError {
Expand Down Expand Up @@ -262,7 +262,7 @@ extension JSON {
// times.
self = JSON.convertToJSON(result)
} catch {
throw JSONDecodingError.malformed
throw JSONDecodingError.malformed(json: String(data: data, encoding: .utf8) ?? data.description, underlyingError: error)
}
}

Expand Down

0 comments on commit 5446eab

Please sign in to comment.