[go: nahoru, domu]

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

Convert FirebaseError to TypeScript #1521

Merged
merged 16 commits into from
Jul 23, 2019
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Avoid destruction of properties
  • Loading branch information
merlinnot committed Jul 17, 2019
commit 5868765bee62fb0e5f365865a708f325fbc3240a
23 changes: 8 additions & 15 deletions src/error.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { defaultTo } from "lodash";

interface FirebaseErrorOptions {
merlinnot marked this conversation as resolved.
Show resolved Hide resolved
children?: unknown[];
context?: unknown;
Expand All @@ -19,23 +21,14 @@ export class FirebaseError extends Error implements FirebaseErrorOptions {
readonly original: Error | undefined;
readonly status: number;
merlinnot marked this conversation as resolved.
Show resolved Hide resolved

constructor(
message: string,
{
children = DEFAULT_CHILDREN,
context,
exit = DEFAULT_EXIT,
original,
status = DEFAULT_STATUS,
}: FirebaseErrorOptions = {}
) {
constructor(message: string, options: FirebaseErrorOptions = {}) {
super();

this.children = children;
this.context = context;
this.exit = exit;
this.children = defaultTo(options.children, DEFAULT_CHILDREN);
this.context = options.context;
this.exit = defaultTo(options.exit, DEFAULT_EXIT);
this.message = message;
this.original = original;
this.status = status;
this.original = options.original;
this.status = defaultTo(options.status, DEFAULT_STATUS);
}
}