Skip to content

Commit

Permalink
Change error to SQSError
Browse files Browse the repository at this point in the history
  • Loading branch information
lucacasonato committed Aug 3, 2020
1 parent 6ee2ba2 commit 9b78000
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/queue.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { AWSSignerV4, sha256 } from "../deps.ts";
import type { SendMessageOptions } from "./types.ts";
import { SQSError } from "./error.ts";

export interface SQSQueueConfig {
queueURL: string;
Expand Down Expand Up @@ -48,10 +49,11 @@ export class SQSQueue {
const url = `/?Action=SendMessage&MessageBody=${
encodeURIComponent(options.body)
}`;
const resp = await this._doRequest(url, "GET", {});
if (!resp.ok) {
throw new Error(
`Failed to send message: ${resp.statusText}\n${await resp.text()}`,
const res = await this._doRequest(url, "GET", {});
if (!res.ok) {
throw new SQSError(
`Failed to send message: ${res.status} ${res.statusText}`,
await res.text(),
);
}
return;
Expand Down

0 comments on commit 9b78000

Please sign in to comment.