Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Type s3 errors #42

Merged
merged 3 commits into from
Mar 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/heavy-apes-remember.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@effect-aws/client-s3": minor
---

extended errors in s3 service
26 changes: 25 additions & 1 deletion packages/client-s3/src/Errors.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,34 @@
import { S3ServiceException } from "@aws-sdk/client-s3";
import type {
S3ServiceException,
BucketAlreadyExists,
BucketAlreadyOwnedByYou,
InvalidObjectState,
NoSuchBucket,
NoSuchKey,
NoSuchUpload,
NotFound,
ObjectAlreadyInActiveTierError as ObjectAlreadyInActiveTierException,
ObjectNotInActiveTierError as ObjectNotInActiveTierException,
} from "@aws-sdk/client-s3";
import * as Data from "effect/Data";

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

export type BucketAlreadyExistsError = TaggedException<BucketAlreadyExists>;
export type BucketAlreadyOwnedByYouError =
TaggedException<BucketAlreadyOwnedByYou>;
export type InvalidObjectStateError = TaggedException<InvalidObjectState>;
export type NoSuchBucketError = TaggedException<NoSuchBucket>;
export type NoSuchKeyError = TaggedException<NoSuchKey>;
export type NoSuchUploadError = TaggedException<NoSuchUpload>;
export type NotFoundError = TaggedException<NotFound>;
export type ObjectAlreadyInActiveTierError =
TaggedException<ObjectAlreadyInActiveTierException>;
export type ObjectNotInActiveTierError =
TaggedException<ObjectNotInActiveTierException>;

export type S3ServiceError = TaggedException<
S3ServiceException & { name: "S3ServiceError" }
>;
Expand Down
20 changes: 15 additions & 5 deletions packages/client-s3/src/S3ClientInstanceConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,21 @@ export const makeDefaultS3ClientInstanceConfig: Effect.Effect<S3ClientConfig> =

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);
},
},
};
});
Expand Down
Loading
Loading