Skip to content

Commit 3ff1f67

Browse files
committed
Include part of remote spec content in error
Makes it easier to debug why loading a remote spec fails
1 parent 3798a44 commit 3ff1f67

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

src/app/api/remotes/[encodedRemoteConfig]/route.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ export async function GET(_req: NextRequest, { params }: { params: Promise<Remot
5555
} else if (error.name === ErrorName.TIMEOUT) {
5656
return makeAPIErrorResponse(408, "The operation timed out.")
5757
} else if (error.name === ErrorName.NOT_JSON_OR_YAML) {
58-
return makeAPIErrorResponse(400, "Url does not point to a JSON or YAML file.")
58+
return makeAPIErrorResponse(400, error.message)
5959
} else if (error.name === ErrorName.URL_MAY_NOT_INCLUDE_BASIC_AITH) {
6060
return makeAPIErrorResponse(400, "Url may not include basic auth.")
6161
} else {

src/common/utils/fileUtils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ export function checkIfJsonOrYaml(fileText: string) {
6666
try {
6767
parseYaml(fileText) // will also parse JSON as it is a subset of YAML
6868
} catch {
69-
const error = new Error("File is not JSON or YAML")
69+
const error = new Error("File is not JSON or YAML. Content: " + fileText.slice(0, 1000));
7070
error.name = ErrorName.NOT_JSON_OR_YAML
7171
throw error
7272
}

0 commit comments

Comments
 (0)