Skip to content

Commit

Permalink
Fix Result.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
amckinney committed Dec 10, 2024
1 parent f70d537 commit d654a12
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,7 @@ export class DynamicSnippetsGenerator extends AbstractDynamicSnippetsGenerator<
return result.getResponseOrThrow({ endpoint: request.endpoint });
}

public generateSync(
request: DynamicSnippets.EndpointSnippetRequest
): DynamicSnippets.EndpointSnippetResponse {
public generateSync(request: DynamicSnippets.EndpointSnippetRequest): DynamicSnippets.EndpointSnippetResponse {
const endpoints = this.context.resolveEndpointLocationOrThrow(request.endpoint);
if (endpoints.length === 0) {
throw new Error(`No endpoints found that match "${request.endpoint.method} ${request.endpoint.path}"`);
Expand Down Expand Up @@ -92,4 +90,4 @@ export class DynamicSnippetsGenerator extends AbstractDynamicSnippetsGenerator<
}
return result.getResponseOrThrow({ endpoint: request.endpoint });
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,7 @@ export class EndpointSnippetGenerator {
private context: DynamicSnippetsGeneratorContext;
private formatter: AbstractFormatter | undefined;

constructor({
context,
formatter
}: {
context: DynamicSnippetsGeneratorContext;
formatter?: AbstractFormatter;
}) {
constructor({ context, formatter }: { context: DynamicSnippetsGeneratorContext; formatter?: AbstractFormatter }) {
this.context = context;
this.formatter = formatter;
}
Expand Down Expand Up @@ -60,7 +54,6 @@ export class EndpointSnippetGenerator {
});
}


private buildCodeBlock({
endpoint,
snippet
Expand Down
15 changes: 3 additions & 12 deletions generators/go-v2/dynamic-snippets/src/Result.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { DynamicSnippetsGeneratorContext } from "./context/DynamicSnippetsGeneratorContext";
import { ErrorReporter } from "./context/ErrorReporter";
import { dynamic } from "@fern-api/dynamic-ir-sdk/api";
import { dynamic } from "@fern-fern/ir-sdk/api";

export class Result {
public reporter: ErrorReporter | undefined;
Expand All @@ -13,13 +13,7 @@ export class Result {
this.err = undefined;
}

public update({
context,
snippet,
}: {
context: DynamicSnippetsGeneratorContext;
snippet: string;
}) {
public update({ context, snippet }: { context: DynamicSnippetsGeneratorContext; snippet: string }): void {
if (this.reporter == null || this.reporter.size() > context.errors.size()) {
this.reporter = context.errors.clone();
this.snippet = snippet;
Expand All @@ -33,9 +27,6 @@ export class Result {
errors: this.reporter.toDynamicSnippetErrors()
};
}
throw (
this.err ??
new Error(`Failed to generate snippet for endpoint "${endpoint.method} ${endpoint.path}"`)
);
throw this.err ?? new Error(`Failed to generate snippet for endpoint "${endpoint.method} ${endpoint.path}"`);
}
}

0 comments on commit d654a12

Please sign in to comment.