Skip to content

Commit 547e1aa

Browse files
committed
fix: update exports
1 parent 287b60f commit 547e1aa

File tree

5 files changed

+25
-23
lines changed

5 files changed

+25
-23
lines changed

src/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import {
55
generateMethodResultId,
66
ContentDescriptorNotFoundInMethodError,
77
} from "./generate-method-id";
8-
import { MethodCallValidator, ParameterValidationError } from "./method-call-validator";
8+
import { MethodCallValidator, ParameterValidationError, MethodNotFoundError } from "./method-call-validator";
99
import readSchemaFromFile from "./get-open-rpc-document-from-file";
1010
import fetchUrlSchema from "./get-open-rpc-document-from-url";
1111

@@ -18,6 +18,7 @@ export {
1818
validateOpenRPCDocument,
1919
MethodCallValidator,
2020
ParameterValidationError,
21+
MethodNotFoundError,
2122
OpenRPCDocumentValidationError,
2223
OpenRPCDocumentDereferencingError,
2324
ContentDescriptorNotFoundInMethodError,

src/method-call-validator/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import MethodCallValidator from "./method-call-validator";
22
import ParameterValidationError from "./parameter-validation-error";
3+
import MethodNotFoundError from "./method-not-found-error";
34

4-
export { MethodCallValidator, ParameterValidationError };
5+
export { MethodCallValidator, ParameterValidationError, MethodNotFoundError };
Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import MethodCallMethodNotFoundError from "./method-not-found-error";
1+
import MethodNotFoundError from "./method-not-found-error";
22
import { OpenRPC } from "@open-rpc/meta-schema";
33

44
const exampleDoc = {
@@ -10,25 +10,26 @@ const exampleDoc = {
1010
openrpc: "1.1.9",
1111
} as OpenRPC;
1212

13-
describe("MethodCallMethodNotFoundError", () => {
13+
describe("MethodNotFoundError", () => {
1414
it("can be instantiated", () => {
15-
const error = new MethodCallMethodNotFoundError("floobar", exampleDoc, ["abc", 123]);
16-
expect(error).toBeInstanceOf(MethodCallMethodNotFoundError);
15+
const error = new MethodNotFoundError("floobar", exampleDoc, ["abc", 123]);
16+
expect(error).toBeInstanceOf(MethodNotFoundError);
1717
});
1818

1919
it("works when no params passed", () => {
20-
const error = new MethodCallMethodNotFoundError("floobar", exampleDoc);
21-
expect(error).toBeInstanceOf(MethodCallMethodNotFoundError);
20+
const error = new MethodNotFoundError("floobar", exampleDoc);
21+
expect(error).toBeInstanceOf(MethodNotFoundError);
2222
});
2323

2424
it("properly parses params in to a string", () => {
25-
const error = new MethodCallMethodNotFoundError("floobar", exampleDoc, ["abc", { abc: 123 }, 123]);
26-
expect(error).toBeInstanceOf(MethodCallMethodNotFoundError);
25+
const error = new MethodNotFoundError("floobar", exampleDoc, ["abc", { abc: 123 }, 123]);
26+
expect(error).toBeInstanceOf(MethodNotFoundError);
2727
expect(error.message).toBe(`Method Not Found Error for OpenRPC API named "testerino"
2828
The requested method: "floobar" not a valid method.
29-
30-
debug info:
31-
params: "abc", {"abc":123}, 123`);
29+
Params:
30+
"abc"
31+
{"abc":123}
32+
123`);
3233
});
3334

3435
it("it handles openrpc docs with a method", () => {
@@ -42,8 +43,8 @@ debug info:
4243
},
4344
},
4445
];
45-
const error = new MethodCallMethodNotFoundError("floobar", exampleDoc, ["abc", { abc: 123 }, 123]);
46-
expect(error).toBeInstanceOf(MethodCallMethodNotFoundError);
46+
const error = new MethodNotFoundError("floobar", exampleDoc, ["abc", { abc: 123 }, 123]);
47+
expect(error).toBeInstanceOf(MethodNotFoundError);
4748
expect(error.message).toContain("Valid method names are as follows: dooptiedoo");
4849
});
4950
});

src/method-call-validator/method-not-found-error.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ import { OpenRPC } from "@open-rpc/meta-schema";
33
/**
44
* Provides an error interface for handling when a method is trying to be called but does not exist.
55
*/
6-
export default class MethodCallMethodNotFoundError implements Error {
7-
public name = "MethodCallMethodNotFoundError";
6+
export default class MethodNotFoundError implements Error {
7+
public name = "MethodNotFoundError";
88
public message: string;
99

1010
/**
@@ -32,11 +32,10 @@ export default class MethodCallMethodNotFoundError implements Error {
3232
if (receievedParams.length > 0) {
3333
const stringedParams = receievedParams
3434
.map((p) => { try { return JSON.stringify(p); } catch (e) { return p; } })
35-
.join(", ");
35+
.join("\n");
3636

37-
msg.push("");
38-
msg.push("debug info:");
39-
msg.push(` params: ${stringedParams}`);
37+
msg.push("Params:");
38+
msg.push(stringedParams);
4039
}
4140

4241
this.message = msg.join("\n");

src/method-call-validator/parameter-validation-error.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ import { Schema } from "@open-rpc/meta-schema";
44
/**
55
* Provides an error interface for handling when a function call has invalid parameters.
66
*/
7-
export default class MethodCallParameterValidationError implements Error {
8-
public name = "MethodCallParameterValidationError";
7+
export default class ParameterValidationError implements Error {
8+
public name = "ParameterValidationError";
99
public message: string;
1010

1111
/**

0 commit comments

Comments
 (0)