Skip to content

Commit 12d9b29

Browse files
XatMassacrElinhe0x0
authored andcommitted
APIReference-Errors.md (xitu#52)
1 parent 97811b7 commit 12d9b29

File tree

1 file changed

+11
-18
lines changed

1 file changed

+11
-18
lines changed

site/graphql-js/APIReference-Errors.md

Lines changed: 11 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -7,44 +7,43 @@ sublinks: formatError,GraphQLError,locatedError,syntaxError
77
next: /graphql-js/execution/
88
---
99

10-
The `graphql/error` module is responsible for creating and formatting
11-
GraphQL errors. You can import either from the `graphql/error` module, or from the root `graphql` module. For example:
10+
`graphql/error` 模块负责创建和格式化 GraphQL 的错误信息。你可以直接从 `graphql/error` 模块导入,也可以从 `graphql` 这个根模块导入。举例来说就是这样:
1211

1312
```js
1413
import { GraphQLError } from 'graphql'; // ES6
1514
var { GraphQLError } = require('graphql'); // CommonJS
1615
```
1716

18-
## Overview
17+
## 概述
1918

2019
<ul class="apiIndex">
2120
<li>
2221
<a href="#graphqlerror">
2322
<pre>class GraphQLError</pre>
24-
A representation of an error that occurred within GraphQL.
23+
GraphQLError 表示 GraphQL 产生的错误信息。
2524
</a>
2625
</li>
2726
<li>
2827
<a href="#syntaxerror">
2928
<pre>function syntaxError</pre>
30-
Produces a GraphQLError representing a syntax error.
29+
产生一个表示语法错误的 GraphQLError
3130
</a>
3231
</li>
3332
<li>
3433
<a href="#locatedError">
3534
<pre>function locatedError</pre>
36-
Produces a new GraphQLError aware of the location responsible for the error.
35+
产生一个新的负责错误定位的 GraphQLError
3736
</a>
3837
</li>
3938
<li>
4039
<a href="#formaterror">
4140
<pre>function formatError</pre>
42-
Format an error according to the rules described by the Response Format.
41+
根据响应格式的规则描述来格式化一条错误信息。
4342
</a>
4443
</li>
4544
</ul>
4645

47-
## Errors
46+
## 错误信息
4847

4948
### GraphQLError
5049

@@ -60,9 +59,7 @@ class GraphQLError extends Error {
6059
}
6160
```
6261
63-
A representation of an error that occurred within GraphQL. Contains
64-
information about where in the query the error occurred for debugging. Most
65-
commonly constructed with `locatedError` below.
62+
GraphQLError 表示 GraphQL 产生的错误信息。它包含一些用于调试的信息,比如查询语句中错误发生的位置。最常见的错误信息就是下面的的 `locatedError`
6663
6764
### syntaxError
6865
@@ -74,18 +71,15 @@ function syntaxError(
7471
): GraphQLError;
7572
```
7673

77-
Produces a GraphQLError representing a syntax error, containing useful
78-
descriptive information about the syntax error's position in the source.
74+
产生一个表示语法错误的 GraphQLError,它包含原始语句中语法错误具体定位的描述性信息。
7975

8076
### locatedError
8177

8278
```js
8379
function locatedError(error: ?Error, nodes: Array<any>): GraphQLError {
8480
```
8581
86-
Given an arbitrary Error, presumably thrown while attempting to execute a
87-
GraphQL operation, produce a new GraphQLError aware of the location in the
88-
document responsible for the original Error.
82+
当尝试执行 GraphQL 操作时抛出的任意一个错误,都会产生一个新的负责原始错误文档定位的 GraphQLError 。
8983
9084
### formatError
9185
@@ -103,5 +97,4 @@ type GraphQLErrorLocation = {
10397
};
10498
```
10599
106-
Given a GraphQLError, format it according to the rules described by the
107-
Response Format, Errors section of the GraphQL Specification.
100+
给定一个 GraphQLError,根据 GraphQL 规范中的响应格式和错误分类的规则描述来格式化错误信息。

0 commit comments

Comments
 (0)