• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

rdf-elixir / jsonld-ex / de3ca9b1dae3a8dffda3dec6d69d62a58ee3622e

10 Apr 2025 03:31PM UTC coverage: 91.542%. Remained the same
de3ca9b1dae3a8dffda3dec6d69d62a58ee3622e

push

github

marcelotto
Remove unused HTML versions of test manifests

1775 of 1939 relevant lines covered (91.54%)

4387.12 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

88.33
/lib/json/ld/exceptions.ex
1
defmodule JSON.LD.Error do
2
  @moduledoc """
3
  The base exception for all JSON-LD errors.
4

5
  See <https://w3c.github.io/json-ld-api/#jsonlderror>
6
  """
7
  @enforce_keys [:code, :message]
8
  defexception [:code, :message]
9

10
  def message(%__MODULE__{code: code, message: message}) do
11
    "#{code}: #{message}"
28✔
12
  end
13

14
  @doc """
15
  Two properties which expand to the same keyword have been detected.
16
  This might occur if a keyword and an alias thereof are used at the same time.
17
  """
18
  def colliding_keywords(keyword) do
19
    exception(
12✔
20
      code: "colliding keywords",
21
      message: "#{keyword} already exists in result"
12✔
22
    )
23
  end
24

25
  @doc """
26
  Multiple conflicting indexes have been found for the same node.
27
  """
28
  def conflicting_indexes(index1, index2) do
29
    exception(
4✔
30
      code: "conflicting indexes",
31
      message: "Conflicting indexes #{inspect(index1)} and #{inspect(index2)}"
32
    )
33
  end
34

35
  @doc """
36
  Maximum number of `@context` URLs exceeded.
37
  """
38
  def context_overflow(context) do
39
    exception(
×
40
      code: "context overflow",
41
      message: "Maximum number of @context URLs exceeded: #{inspect(context)}"
42
    )
43
  end
44

45
  @doc """
46
  A cycle in IRI mappings has been detected.
47
  """
48
  def cyclic_iri_mapping(term) do
49
    exception(
8✔
50
      code: "cyclic IRI mapping",
51
      message: "Cyclical term dependency found: #{inspect(term)}"
52
    )
53
  end
54

55
  @doc """
56
  An `@id` entry was encountered whose value was not a string.
57
  """
58
  def invalid_id_value(value) do
59
    exception(
8✔
60
      code: "invalid @id value",
61
      message: "#{inspect(value)} is not a valid @id value"
62
    )
63
  end
64

65
  @doc """
66
  An invalid value for `@import` has been found.
67
  """
68
  def invalid_import_value(value) do
69
    exception(
16✔
70
      code: "invalid @import value",
71
      message: "#{inspect(value)} is not a valid @import value"
72
    )
73
  end
74

75
  @doc """
76
  An included block contains an invalid value.
77
  """
78
  def invalid_included_value(value \\ nil) do
79
    message = "values of @included must expand to node objects"
36✔
80

81
    exception(
36✔
82
      code: "invalid @included value",
83
      message:
84
        if(value,
85
          do: "#{inspect(value)} is not a valid @included value; #{message}",
36✔
86
          else: message
×
87
        )
88
    )
89
  end
90

91
  @doc """
92
  An `@index` member was encountered whose value was not a string.
93
  """
94
  def invalid_index_value(value) do
95
    exception(
8✔
96
      code: "invalid @index value",
97
      message: "#{inspect(value)} is not a valid @index value"
98
    )
99
  end
100

101
  @doc """
102
  An invalid value for `@nest` has been found.
103
  """
104
  def invalid_nest_value(message) do
105
    exception(
56✔
106
      code: "invalid @nest value",
107
      message: message
108
    )
109
  end
110

111
  @doc """
112
  An invalid value for `@prefix` has been found.
113
  """
114
  def invalid_prefix_value(value) do
115
    exception(
16✔
116
      code: "invalid @prefix value",
117
      message: "#{inspect(value)} is not a valid @prefix value; must be a boolean"
118
    )
119
  end
120

121
  @doc """
122
  An invalid value for `@propagate` has been found.
123
  """
124
  def invalid_propagate_value(value) do
125
    exception(
12✔
126
      code: "invalid @propagate value",
127
      message: "#{inspect(value)} is not a valid @propagate value; must be a boolean"
128
    )
129
  end
130

131
  @doc """
132
  An invalid value for `@protected` has been found.
133
  """
134
  def invalid_protected_value(value) do
135
    exception(
×
136
      code: "invalid @protected value",
137
      message: "#{inspect(value)} is not a valid @protected value; must be a boolean"
138
    )
139
  end
140

141
  @doc """
142
  An invalid value for an `@reverse` entry has been detected, i.e., the value was not a map.
143
  """
144
  def invalid_reverse_value(value) do
145
    exception(
8✔
146
      code: "invalid @reverse value",
147
      message: "#{inspect(value)} is not a valid @reverse value; must be a map"
148
    )
149
  end
150

151
  @doc """
152
  The `@version` entry was used in a context with an out of range value.
153
  """
154
  def invalid_version_value(value) do
155
    exception(
24✔
156
      code: "invalid @version value",
157
      message: "#{inspect(value)} is not a valid @version value"
158
    )
159
  end
160

161
  @doc """
162
  The value of @direction is not "ltr", "rtl", or null and thus invalid.
163
  """
164
  def invalid_base_direction(direction) do
165
    exception(
16✔
166
      code: "invalid base direction",
167
      message:
168
        "#{inspect(direction)} is not a valid base direction; must be 'ltr', 'rtl', or null"
169
    )
170
  end
171

172
  @doc """
173
  An invalid base IRI has been detected, i.e., it is neither an absolute IRI nor null.
174
  """
175
  def invalid_base_iri(base) do
176
    exception(
8✔
177
      code: "invalid base IRI",
178
      message: "#{inspect(base)} is not a valid absolute IRI"
179
    )
180
  end
181

182
  def invalid_base_iri(base, :relative_without_active_base) do
183
    exception(
×
184
      code: "invalid base IRI",
185
      message: "#{inspect(base)} is a relative IRI, but no active base IRI defined"
186
    )
187
  end
188

189
  @doc """
190
  An `@container` entry was encountered whose value was not one of the following strings: `@list`, `@set`, `@language`, `@index`, `@id`, `@graph`, or `@type`.
191
  """
192
  def invalid_container_mapping(message) do
193
    exception(
40✔
194
      code: "invalid container mapping",
195
      message: message
196
    )
197
  end
198

199
  @doc """
200
  An entry in a context is invalid due to processing mode incompatibility.
201
  """
202
  def invalid_context_entry(message) do
203
    exception(
32✔
204
      code: "invalid context entry",
205
      message: message
206
    )
207
  end
208

209
  @doc """
210
  An attempt was made to nullify a context containing protected term definitions.
211
  """
212
  def invalid_context_nullification do
213
    exception(
48✔
214
      code: "invalid context nullification",
215
      message: "Cannot nullify a context containing protected term definitions"
216
    )
217
  end
218

219
  @doc """
220
  The value of the default language is not a string or null and thus invalid.
221
  """
222
  def invalid_default_language(language) do
223
    exception(
12✔
224
      code: "invalid default language",
225
      message: "#{inspect(language)} is not a valid language value"
226
    )
227
  end
228

229
  @doc """
230
  A local context contains a term that has an invalid or missing IRI mapping.
231
  """
232
  def invalid_iri_mapping(message) do
233
    exception(
108✔
234
      code: "invalid IRI mapping",
235
      message: message
236
    )
237
  end
238

239
  @doc """
240
  An invalid JSON literal was detected.
241
  """
242
  def invalid_json_literal(value) do
243
    exception(
8✔
244
      code: "invalid JSON literal",
245
      message: "#{inspect(value)} is not a valid JSON literal"
246
    )
247
  end
248

249
  @doc """
250
  An invalid keyword alias definition has been encountered.
251
  """
252
  def invalid_keyword_alias(message) do
253
    exception(
8✔
254
      code: "invalid keyword alias",
255
      message: message
256
    )
257
  end
258

259
  @doc """
260
  An invalid value in a language map has been detected. It MUST be a string or an array of strings.
261
  """
262
  def invalid_language_map_value(value) do
263
    exception(
8✔
264
      code: "invalid language map value",
265
      message: "#{inspect(value)} is not a valid language map value"
266
    )
267
  end
268

269
  @doc """
270
  An `@language` entry in a term definition was encountered whose value was neither a string nor null and thus invalid.
271
  """
272
  def invalid_language_mapping(language) do
273
    exception(
8✔
274
      code: "invalid language mapping",
275
      message:
276
        "#{inspect(language)} is not a valid language mapping; @language must be a string or null"
277
    )
278
  end
279

280
  @doc """
281
  A language-tagged string with an invalid language value was detected.
282
  """
283
  def invalid_language_tagged_string(value) do
284
    exception(
16✔
285
      code: "invalid language-tagged string",
286
      message: "#{inspect(value)} has an invalid language tag"
287
    )
288
  end
289

290
  @doc """
291
  A number, `true`, or `false` with an associated language tag was detected.
292
  """
293
  def invalid_language_tagged_value(value) do
294
    exception(
8✔
295
      code: "invalid language-tagged value",
296
      message: "#{inspect(value)} cannot be language-tagged"
297
    )
298
  end
299

300
  @doc """
301
  An invalid local context was detected.
302
  """
303
  def invalid_local_context(context) do
304
    exception(
8✔
305
      code: "invalid local context",
306
      message: "#{inspect(context)} is not a valid local context"
307
    )
308
  end
309

310
  @doc """
311
  No valid context document has been found for a referenced remote context.
312
  """
313
  def invalid_remote_context(invalid: context) do
314
    exception(
16✔
315
      code: "invalid remote context",
316
      message: "Context is not a valid JSON object: #{inspect(context)}"
317
    )
318
  end
319

320
  def invalid_remote_context(message) do
321
    exception(
×
322
      code: "invalid remote context",
323
      message: message
324
    )
325
  end
326

327
  @doc """
328
  An invalid reverse property definition has been detected.
329
  """
330
  def invalid_reverse_property(message) do
331
    exception(
32✔
332
      code: "invalid reverse property",
333
      message: message
334
    )
335
  end
336

337
  @doc """
338
  An invalid reverse property map has been detected. No keywords apart from `@context` are allowed in reverse property maps.
339
  """
340
  def invalid_reverse_property_map do
341
    exception(
12✔
342
      code: "invalid reverse property map",
343
      message:
344
        "An invalid reverse property map has been detected. No keywords apart from `@context` are allowed in reverse property maps."
345
    )
346
  end
347

348
  @doc """
349
  An invalid value for a reverse property has been detected. The value of an inverse property must be a node object.
350
  """
351
  def invalid_reverse_property_value(value) do
352
    exception(
16✔
353
      code: "invalid reverse property value",
354
      message: "invalid value for a reverse property in #{inspect(value)}"
355
    )
356
  end
357

358
  @doc """
359
  The local context defined within a term definition is invalid.
360
  """
361
  def invalid_scoped_context(message) do
362
    exception(
16✔
363
      code: "invalid scoped context",
364
      message: message
365
    )
366
  end
367

368
  @doc """
369
  A script element in HTML input which is the target of a fragment identifier does not have an appropriate type attribute.
370
  """
371
  def invalid_script_element(message) do
372
    exception(
×
373
      code: "invalid script element",
374
      message: message
375
    )
376
  end
377

378
  @doc """
379
  A set object or list object with disallowed members has been detected.
380
  """
381
  def invalid_set_or_list_object(value) do
382
    exception(
8✔
383
      code: "invalid set or list object",
384
      message: "set or list object with disallowed members: #{inspect(value)}"
385
    )
386
  end
387

388
  @doc """
389
  An invalid term definition has been detected.
390
  """
391
  def invalid_term_definition(message) do
392
    exception(
108✔
393
      code: "invalid term definition",
394
      message: message
395
    )
396
  end
397

398
  @doc """
399
  An `@type` entry in a term definition was encountered whose value could not be expanded to an IRI.
400
  """
401
  def invalid_type_mapping(message: message) do
402
    exception(
8✔
403
      code: "invalid type mapping",
404
      message: message
405
    )
406
  end
407

408
  def invalid_type_mapping(type) do
409
    exception(
56✔
410
      code: "invalid type mapping",
411
      message: "#{inspect(type)} is not a valid type mapping"
412
    )
413
  end
414

415
  @doc """
416
  An invalid value for an `@type` entry has been detected, i.e., the value was neither a string nor an array of strings.
417
  """
418
  def invalid_type_value(value) do
419
    exception(
12✔
420
      code: "invalid type value",
421
      message: "#{inspect(value)} is not a valid type value"
422
    )
423
  end
424

425
  @doc """
426
  A typed value with an invalid type was detected.
427
  """
428
  def invalid_typed_value(value, type) do
429
    exception(
28✔
430
      code: "invalid typed value",
431
      message: "#{inspect(value)} is not valid for type #{inspect(type)}"
432
    )
433
  end
434

435
  @doc """
436
  A value object with disallowed entries has been detected.
437
  """
438
  def invalid_value_object(message) do
439
    exception(
32✔
440
      code: "invalid value object",
441
      message: message
442
    )
443
  end
444

445
  @doc """
446
  An invalid value for the `@value` entry of a value object has been detected, i.e., it is neither a scalar nor `null`.
447
  """
448
  def invalid_value_object_value(value) do
449
    exception(
16✔
450
      code: "invalid value object value",
451
      message: "#{inspect(value)} is not a valid value object; must be a scalar or null"
452
    )
453
  end
454

455
  @doc """
456
  An invalid vocabulary mapping has been detected, i.e., it is neither an IRI nor `null`.
457
  """
458
  def invalid_vocab_mapping(message: message) do
459
    exception(
×
460
      code: "invalid vocab mapping",
461
      message: message
462
    )
463
  end
464

465
  def invalid_vocab_mapping(vocab) do
466
    exception(
12✔
467
      code: "invalid vocab mapping",
468
      message:
469
        "#{inspect(vocab)} is not a valid vocabulary mapping; must be an absolute IRI or null"
470
    )
471
  end
472

473
  @doc """
474
  When compacting an IRI would result in an IRI which could be confused with a compact IRI (because its IRI scheme matches a term definition and it has no IRI authority).
475
  """
476
  def iri_confused_with_prefix(iri, prefix) do
477
    exception(
4✔
478
      code: "IRI confused with prefix",
479
      message: "Absolute IRI '#{iri}' confused with prefix '#{prefix}'"
4✔
480
    )
481
  end
482

483
  @doc """
484
  A keyword redefinition has been detected.
485
  """
486
  def keyword_redefinition(message) do
487
    exception(
232✔
488
      code: "keyword redefinition",
489
      message: message
490
    )
491
  end
492

493
  @doc """
494
  The document could not be loaded or parsed as JSON.
495
  """
496
  def loading_document_failed(message) do
497
    exception(
40✔
498
      code: "loading document failed",
499
      message: message
500
    )
501
  end
502

503
  @doc """
504
  There was a problem encountered loading a remote context.
505
  """
506
  def loading_remote_context_failed(url, reason) do
507
    exception(
16✔
508
      code: "loading remote context failed",
509
      message: "Could not load remote context #{url}: #{inspect(reason)}"
16✔
510
    )
511
  end
512

513
  @doc """
514
  Multiple HTTP Link Headers using the http://www.w3.org/ns/json-ld#context link relation have been detected.
515
  """
516
  def multiple_context_link_headers do
517
    exception(
8✔
518
      code: "multiple context link headers",
519
      message:
520
        "Multiple HTTP Link Headers using the http://www.w3.org/ns/json-ld#context link relation have been detected"
521
    )
522
  end
523

524
  @doc """
525
  An attempt was made to change the processing mode which is incompatible with the previous specified version.
526
  """
527
  def processing_mode_conflict do
528
    exception(
12✔
529
      code: "processing mode conflict",
530
      message: "Processing mode conflict"
531
    )
532
  end
533

534
  @doc """
535
  An attempt was made to redefine a protected term.
536
  """
537
  def protected_term_redefinition(term) do
538
    exception(
124✔
539
      code: "protected term redefinition",
540
      message: "#{inspect(term)} is a protected term and cannot be redefined"
541
    )
542
  end
543
end
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc