Skip to content

Commit da81b8a

Browse files
authored
Fix Github parse error extending the wrong error class (#3)
1 parent bd0fdce commit da81b8a

1 file changed

Lines changed: 13 additions & 9 deletions

File tree

src/lib/integrations/github.ts

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,18 @@
11
import { findDOMNodeByContent } from "@lib/utils/findDOMNodeByContent";
22
import { Integration } from "./core";
3-
import { EIntegrationParseErrorData, EIntegrationTargetError } from "./error";
4-
import { EError, EErrorOptions } from "@lib/utils/error";
3+
import {
4+
EIntegrationParseError,
5+
EIntegrationParseErrorData,
6+
EIntegrationTargetError,
7+
} from "./error";
8+
import { EErrorOptions } from "@lib/utils/error";
59
import { WithPartial } from "@lib/utils/WithPartial";
610
import _ from "lodash";
711

812
type EGithubParseErrorData = EIntegrationParseErrorData & {
913
integration: "github";
1014
};
11-
export class EGithubParseError extends EError<EGithubParseErrorData> {
15+
export class EGithubParseError extends EIntegrationParseError {
1216
constructor({
1317
message = "Unable to extract repository or branch from URL",
1418
data,
@@ -50,7 +54,7 @@ export const github: Integration = {
5054
if (!results) {
5155
throw new EGithubParseError({
5256
data: {
53-
url: window.location.href,
57+
url: url.toString(),
5458
integration: "github",
5559
cause: "no match",
5660
process: "repo",
@@ -61,7 +65,7 @@ export const github: Integration = {
6165
if (_.isEmpty(repo)) {
6266
throw new EGithubParseError({
6367
data: {
64-
url: window.location.href,
68+
url: url.toString(),
6569
integration: "github",
6670
cause: "empty match",
6771
process: "repo",
@@ -76,7 +80,7 @@ export const github: Integration = {
7680
if (!branchContainer) {
7781
throw new EGithubParseError({
7882
data: {
79-
url: window.location.href,
83+
url: url.toString(),
8084
integration: "github",
8185
cause: "no match",
8286
process: "branch",
@@ -87,7 +91,7 @@ export const github: Integration = {
8791
if (!branch || _.isEmpty(branch)) {
8892
throw new EGithubParseError({
8993
data: {
90-
url: window.location.href,
94+
url: url.toString(),
9195
integration: "github",
9296
cause: "empty match",
9397
process: "branch",
@@ -98,7 +102,7 @@ export const github: Integration = {
98102
} else {
99103
const results =
100104
/[/](?<repo>[^/]+[/][^/]+)([/]?tree[/](?<branch>[^?]+))?/.exec(
101-
window.location.pathname,
105+
url.toString(),
102106
)?.groups;
103107
if (!results) {
104108
throw new EGithubParseError({
@@ -114,7 +118,7 @@ export const github: Integration = {
114118
if (_.isEmpty(branch)) {
115119
throw new EGithubParseError({
116120
data: {
117-
url: window.location.href,
121+
url: url.toString(),
118122
integration: "github",
119123
cause: "empty match",
120124
process: "branch",

0 commit comments

Comments
 (0)