1
+ import { Code , PluginError } from "@/errors" ;
1
2
import { Octokit } from "@octokit/core" ;
2
3
import { retry } from "@octokit/plugin-retry" ;
3
4
import { type Result , ResultAsync } from "neverthrow" ;
4
- import { GithubRepositoriesServiceError } from "./errors" ;
5
5
import starredRepositoriesQuery from "./queries/starredRepositories.gql" ;
6
6
import totalStarredRepositoriesCountQuery from "./queries/totalStarredRepositoriesCount.gql" ;
7
7
import type { GitHubGraphQl } from "./types" ;
@@ -16,7 +16,7 @@ export interface StarredRepositoriesQueryResult {
16
16
export type StarredRepositoriesGenerator = AsyncGenerator <
17
17
Result <
18
18
GitHubGraphQl . StarredRepositoryEdge [ ] ,
19
- GithubRepositoriesServiceError
19
+ PluginError < Code . GithubService >
20
20
> ,
21
21
void ,
22
22
unknown
@@ -30,7 +30,7 @@ export interface IGithubRepositoriesService {
30
30
31
31
getTotalStarredRepositoriesCount ( ) : ResultAsync <
32
32
number ,
33
- GithubRepositoriesServiceError
33
+ PluginError < Code . GithubService >
34
34
> ;
35
35
}
36
36
@@ -52,7 +52,7 @@ export class GithubRepositoriesService implements IGithubRepositoriesService {
52
52
pageSize : number ,
53
53
) : ResultAsync <
54
54
StarredRepositoriesQueryResult ,
55
- GithubRepositoriesServiceError
55
+ PluginError < Code . GithubService >
56
56
> {
57
57
const makeRequest = ResultAsync . fromPromise (
58
58
this . client . graphql < GitHubGraphQl . StarredRepositoriesResponse > (
@@ -62,7 +62,7 @@ export class GithubRepositoriesService implements IGithubRepositoriesService {
62
62
pageSize,
63
63
} ,
64
64
) ,
65
- ( ) => GithubRepositoriesServiceError . RequestFailed ,
65
+ ( ) => new PluginError ( Code . GithubService . RequestFailed ) ,
66
66
) ;
67
67
68
68
return makeRequest . map ( ( response ) => {
@@ -100,13 +100,13 @@ export class GithubRepositoriesService implements IGithubRepositoriesService {
100
100
101
101
public getTotalStarredRepositoriesCount ( ) : ResultAsync <
102
102
number ,
103
- GithubRepositoriesServiceError
103
+ PluginError < Code . GithubService >
104
104
> {
105
105
return ResultAsync . fromPromise (
106
106
this . client . graphql < GitHubGraphQl . StarredRepositoriesResponse > (
107
107
totalStarredRepositoriesCountQuery ,
108
108
) ,
109
- ( ) => GithubRepositoriesServiceError . RequestFailed ,
109
+ ( ) => new PluginError ( Code . GithubService . RequestFailed ) ,
110
110
) . map ( ( response ) => response . viewer . starredRepositories . totalCount ) ;
111
111
}
112
112
}
0 commit comments