Skip to content

Commit

Permalink
Use SpecError in kubernetesAddress declarations
Browse files Browse the repository at this point in the history
  • Loading branch information
ezzatron committed Mar 24, 2024
1 parent db2ef6b commit f439421
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/declaration/kubernetes-address.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
type ExactOptions,
} from "../declaration.js";
import { registerVariable } from "../environment.js";
import { normalize } from "../error.js";
import { SpecError, normalize } from "../error.js";
import { resolveExamples, type Example } from "../example.js";
import { Maybe, map, resolve } from "../maybe.js";
import {
Expand Down Expand Up @@ -182,22 +182,24 @@ function nameToEnv(name: string): string {
return name.replaceAll("-", "_").toUpperCase();
}

class InvalidServiceNameError extends Error {
class InvalidServiceNameError extends SpecError {
constructor(name: string, cause: Error) {
const quotedName = JSON.stringify(name);

super(
`specification for Kubernetes service address is invalid: service name (${quotedName}): ${cause.message}`,
"Kubernetes service address",
new Error(`service name (${quotedName}): ${cause.message}`),
);
}
}

class InvalidPortNameError extends Error {
class InvalidPortNameError extends SpecError {
constructor(name: string, portName: string, cause: Error) {
const quotedName = JSON.stringify(portName);

super(
`specification for Kubernetes ${name} service address is invalid: port name (${quotedName}): ${cause.message}`,
`Kubernetes ${name} service address`,
new Error(`port name (${quotedName}): ${cause.message}`),
);
}
}
Expand Down

0 comments on commit f439421

Please sign in to comment.