Skip to content

Commit

Permalink
feat: errors in client-lambda and client-eventbridge
Browse files Browse the repository at this point in the history
  • Loading branch information
floydspace committed Mar 15, 2024
1 parent 2fd893a commit 4b5ee14
Show file tree
Hide file tree
Showing 11 changed files with 1,456 additions and 458 deletions.
6 changes: 6 additions & 0 deletions .changeset/fast-kings-relax.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@effect-aws/client-eventbridge": minor
"@effect-aws/client-lambda": minor
---

return proper errors in failure channel in eventbridge and lambda services
38 changes: 38 additions & 0 deletions packages/client-eventbridge/src/Errors.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import type {
ConcurrentModificationException,
IllegalStatusException,
InternalException,
InvalidEventPatternException,
InvalidStateException,
LimitExceededException,
ManagedRuleException,
OperationDisabledException,
PolicyLengthExceededException,
ResourceAlreadyExistsException,
ResourceNotFoundException,
} from "@aws-sdk/client-eventbridge";
import * as Data from "effect/Data";

export type TaggedException<T extends { name: string }> = T & {
readonly _tag: T["name"];
};

export type ConcurrentModificationError =
TaggedException<ConcurrentModificationException>;
export type IllegalStatusError = TaggedException<IllegalStatusException>;
export type InternalError = TaggedException<InternalException>;
export type InvalidEventPatternError =
TaggedException<InvalidEventPatternException>;
export type InvalidStateError = TaggedException<InvalidStateException>;
export type LimitExceededError = TaggedException<LimitExceededException>;
export type ManagedRuleError = TaggedException<ManagedRuleException>;
export type OperationDisabledError =
TaggedException<OperationDisabledException>;
export type PolicyLengthExceededError =
TaggedException<PolicyLengthExceededException>;
export type ResourceAlreadyExistsError =
TaggedException<ResourceAlreadyExistsException>;
export type ResourceNotFoundError = TaggedException<ResourceNotFoundException>;

export type SdkError = TaggedException<Error & { name: "SdkError" }>;
export const SdkError = Data.tagged<SdkError>("SdkError");
22 changes: 16 additions & 6 deletions packages/client-eventbridge/src/EventBridgeClientInstanceConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,23 @@ export const makeDefaultEventBridgeClientInstanceConfig: Effect.Effect<EventBrid

return {
logger: {
info: (m) => Effect.logInfo(m).pipe(runSync),
warn: (m) => Effect.logWarning(m).pipe(runSync),
error: (m) => Effect.logError(m).pipe(runSync),
debug: (m) => Effect.logDebug(m).pipe(runSync),
trace: (m) => Effect.logTrace(m).pipe(runSync),
info(m) {
Effect.logInfo(m).pipe(runSync);
},
warn(m) {
Effect.logWarning(m).pipe(runSync);
},
error(m) {
Effect.logError(m).pipe(runSync);
},
debug(m) {
Effect.logDebug(m).pipe(runSync);
},
trace(m) {
Effect.logTrace(m).pipe(runSync);
},
},
} as EventBridgeClientConfig;
};
});

/**
Expand Down
Loading

0 comments on commit 4b5ee14

Please sign in to comment.