Skip to content

Commit

Permalink
fix: add light parsing on d1 execute error message
Browse files Browse the repository at this point in the history
  • Loading branch information
rozenmd committed Jan 30, 2024
1 parent fa628ca commit ee9b161
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions packages/wrangler/src/d1/execute.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -150,12 +150,17 @@ export const Handler = async (args: HandlerOptions): Promise<void> => {
logger.loggerLevel = existingLogLevel;
logger.log(JSON.stringify(response, null, 2));

Check warning on line 151 in packages/wrangler/src/d1/execute.tsx

View check run for this annotation

Codecov / codecov/patch

packages/wrangler/src/d1/execute.tsx#L150-L151

Added lines #L150 - L151 were not covered by tests
}
} catch (e) {
} catch (error) {
if (json) {
logger.loggerLevel = existingLogLevel;

Check warning on line 155 in packages/wrangler/src/d1/execute.tsx

View check run for this annotation

Codecov / codecov/patch

packages/wrangler/src/d1/execute.tsx#L155

Added line #L155 was not covered by tests
logger.log(JSON.stringify({ error: e }, null, 2));
const messageToDisplay =
(error as Error).name === "APIError"
? error
: { text: (error as Error).message };
logger.log(JSON.stringify({ error: messageToDisplay }, null, 2));
process.exit(1);

Check warning on line 161 in packages/wrangler/src/d1/execute.tsx

View check run for this annotation

Codecov / codecov/patch

packages/wrangler/src/d1/execute.tsx#L158-L161

Added lines #L158 - L161 were not covered by tests
} else {
throw e;
throw error;
}
}
};
Expand Down

0 comments on commit ee9b161

Please sign in to comment.