Skip to content

Add dots at the end of error messages #2307

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 25, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/execution/__tests__/executor-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ describe('Execute: Handles basic execution tasks', () => {
});

// $DisableFlowOnNegativeTest
expect(() => execute({ schema })).to.throw('Must provide document');
expect(() => execute({ schema })).to.throw('Must provide document.');
});

it('throws if no schema is provided', () => {
Expand Down
2 changes: 1 addition & 1 deletion src/execution/execute.js
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ export function assertValidExecutionArguments(
document: DocumentNode,
rawVariableValues: ?{ +[variable: string]: mixed, ... },
): void {
devAssert(document, 'Must provide document');
devAssert(document, 'Must provide document.');

// If the schema used for execution is invalid, throw an error.
assertValidSchema(schema);
Expand Down
2 changes: 1 addition & 1 deletion src/jsutils/invariant.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export default function invariant(condition: mixed, message?: string): void {
const booleanCondition = Boolean(condition);
if (!booleanCondition) {
throw new Error(
message != null ? message : 'Unexpected invariant triggered',
message != null ? message : 'Unexpected invariant triggered.',
);
}
}
4 changes: 2 additions & 2 deletions src/language/__tests__/parser-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@ function expectSyntaxError(text) {
describe('Parser', () => {
it('asserts that a source to parse was provided', () => {
// $DisableFlowOnNegativeTest
expect(() => parse()).to.throw('Must provide Source. Received: undefined');
expect(() => parse()).to.throw('Must provide Source. Received: undefined.');
});

it('asserts that an invalid source to parse was provided', () => {
// $DisableFlowOnNegativeTest
expect(() => parse({})).to.throw('Must provide Source. Received: {}');
expect(() => parse({})).to.throw('Must provide Source. Received: {}.');
});

it('parse provides useful errors', () => {
Expand Down
2 changes: 1 addition & 1 deletion src/language/__tests__/printer-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ describe('Printer: Query document', () => {
const badAST = { random: 'Data' };
// $DisableFlowOnNegativeTest
expect(() => print(badAST)).to.throw(
'Invalid AST Node: { random: "Data" }',
'Invalid AST Node: { random: "Data" }.',
);
});

Expand Down
2 changes: 1 addition & 1 deletion src/language/__tests__/schema-printer-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ describe('Printer: SDL document', () => {
const badAST = { random: 'Data' };
// $DisableFlowOnNegativeTest
expect(() => print(badAST)).to.throw(
'Invalid AST Node: { random: "Data" }',
'Invalid AST Node: { random: "Data" }.',
);
});

Expand Down
2 changes: 1 addition & 1 deletion src/language/parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ class Parser {
const sourceObj = typeof source === 'string' ? new Source(source) : source;
devAssert(
sourceObj instanceof Source,
`Must provide Source. Received: ${inspect(sourceObj)}`,
`Must provide Source. Received: ${inspect(sourceObj)}.`,
);

this._lexer = new Lexer(sourceObj);
Expand Down
4 changes: 2 additions & 2 deletions src/language/source.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ export class Source {
this.locationOffset = locationOffset || { line: 1, column: 1 };
devAssert(
this.locationOffset.line > 0,
'line in locationOffset is 1-indexed and must be positive',
'line in locationOffset is 1-indexed and must be positive.',
);
devAssert(
this.locationOffset.column > 0,
'column in locationOffset is 1-indexed and must be positive',
'column in locationOffset is 1-indexed and must be positive.',
);
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/language/visitor.js
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ export function visit(
let result;
if (!Array.isArray(node)) {
if (!isNode(node)) {
throw new Error('Invalid AST Node: ' + inspect(node));
throw new Error(`Invalid AST Node: ${inspect(node)}.`);
}
const visitFn = getVisitFn(visitor, node.kind, isLeaving);
if (visitFn) {
Expand Down
6 changes: 3 additions & 3 deletions src/subscription/__tests__/subscribe-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -337,13 +337,13 @@ describe('Subscription Initialization Phase', () => {
await expectPromiseToThrow(
// $DisableFlowOnNegativeTest
() => subscribe(emailSchema, null),
'Must provide document',
'Must provide document.',
);

await expectPromiseToThrow(
// $DisableFlowOnNegativeTest
() => subscribe({ schema: emailSchema }),
'Must provide document',
'Must provide document.',
);
});

Expand Down Expand Up @@ -386,7 +386,7 @@ describe('Subscription Initialization Phase', () => {

await expectPromiseToThrow(
() => createSubscription(pubsub, invalidEmailSchema),
'Subscription field must return Async Iterable. Received: "test"',
'Subscription field must return Async Iterable. Received: "test".',
);
});

Expand Down
5 changes: 3 additions & 2 deletions src/subscription/subscribe.js
Original file line number Diff line number Diff line change
Expand Up @@ -283,9 +283,10 @@ export function createSourceEventStream(
// Note: isAsyncIterable above ensures this will be correct.
return ((eventStream: any): AsyncIterable<mixed>);
}

throw new Error(
'Subscription field must return Async Iterable. Received: ' +
inspect(eventStream),
'Subscription field must return Async Iterable. ' +
`Received: ${inspect(eventStream)}.`,
);
});
} catch (error) {
Expand Down
2 changes: 1 addition & 1 deletion src/type/__tests__/definition-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ describe('Type System: Objects', () => {
},
});
expect(() => objType.getFields()).to.throw(
'SomeObject.f field config must be an object',
'SomeObject.f field config must be an object.',
);
});

Expand Down
2 changes: 1 addition & 1 deletion src/type/definition.js
Original file line number Diff line number Diff line change
Expand Up @@ -765,7 +765,7 @@ function defineFieldMap<TSource, TContext>(
return mapValue(fieldMap, (fieldConfig, fieldName) => {
devAssert(
isPlainObj(fieldConfig),
`${config.name}.${fieldName} field config must be an object`,
`${config.name}.${fieldName} field config must be an object.`,
);
devAssert(
!('isDeprecated' in fieldConfig),
Expand Down
2 changes: 1 addition & 1 deletion src/utilities/__tests__/assertValidName-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ describe('assertValidName()', () => {

it('throws for non-strings', () => {
// $DisableFlowOnNegativeTest
expect(() => assertValidName({})).to.throw(/Expected string/);
expect(() => assertValidName({})).to.throw('Expected name to be a string.');
});

it('throws for names with invalid characters', () => {
Expand Down
4 changes: 2 additions & 2 deletions src/utilities/__tests__/stripIgnoredCharacters-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,14 +109,14 @@ describe('stripIgnoredCharacters', () => {
it('asserts that a source was provided', () => {
// $DisableFlowOnNegativeTest
expect(() => stripIgnoredCharacters()).to.throw(
'Must provide string or Source. Received: undefined',
'Must provide string or Source. Received: undefined.',
);
});

it('asserts that a valid source was provided', () => {
// $DisableFlowOnNegativeTest
expect(() => stripIgnoredCharacters({})).to.throw(
'Must provide string or Source. Received: {}',
'Must provide string or Source. Received: {}.',
);
});

Expand Down
2 changes: 1 addition & 1 deletion src/utilities/assertValidName.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export function isValidNameError(
name: string,
node?: ASTNode | void,
): GraphQLError | void {
devAssert(typeof name === 'string', 'Expected string');
devAssert(typeof name === 'string', 'Expected name to be a string.');
if (name.length > 1 && name[0] === '_' && name[1] === '_') {
return new GraphQLError(
`Name "${name}" must not begin with "__", which is reserved by GraphQL introspection.`,
Expand Down
2 changes: 1 addition & 1 deletion src/utilities/astFromValue.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ export function astFromValue(value: mixed, type: GraphQLInputType): ?ValueNode {
};
}

throw new TypeError(`Cannot convert value to AST: ${inspect(serialized)}`);
throw new TypeError(`Cannot convert value to AST: ${inspect(serialized)}.`);
}

// Not reachable. All possible input types have been considered.
Expand Down
2 changes: 1 addition & 1 deletion src/utilities/buildASTSchema.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ export function buildASTSchema(
): GraphQLSchema {
devAssert(
documentAST && documentAST.kind === Kind.DOCUMENT,
'Must provide valid Document AST',
'Must provide valid Document AST.',
);

if (!options || !(options.assumeValid || options.assumeValidSDL)) {
Expand Down
4 changes: 2 additions & 2 deletions src/utilities/extendSchema.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ export function extendSchema(

devAssert(
documentAST && documentAST.kind === Kind.DOCUMENT,
'Must provide valid Document AST',
'Must provide valid Document AST.',
);

if (!options || !(options.assumeValid || options.assumeValidSDL)) {
Expand Down Expand Up @@ -211,7 +211,7 @@ export function extendSchema(
function replaceDirectives(
directives: $ReadOnlyArray<GraphQLDirective>,
): Array<GraphQLDirective> {
devAssert(directives, 'schema must have default directives');
devAssert(directives, 'schema must have default directives.');

return directives.map(directive => {
const config = directive.toConfig();
Expand Down
2 changes: 1 addition & 1 deletion src/utilities/stripIgnoredCharacters.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ export function stripIgnoredCharacters(source: string | Source): string {
const sourceObj = typeof source === 'string' ? new Source(source) : source;
if (!(sourceObj instanceof Source)) {
throw new TypeError(
`Must provide string or Source. Received: ${inspect(sourceObj)}`,
`Must provide string or Source. Received: ${inspect(sourceObj)}.`,
);
}

Expand Down
2 changes: 1 addition & 1 deletion src/validation/validate.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export function validate(
typeInfo?: TypeInfo = new TypeInfo(schema),
options?: {| maxErrors?: number |} = { maxErrors: undefined },
): $ReadOnlyArray<GraphQLError> {
devAssert(documentAST, 'Must provide document');
devAssert(documentAST, 'Must provide document.');
// If the schema used for validation is invalid, throw an error.
assertValidSchema(schema);

Expand Down