Search in sources :

Example 11 with TypeDBException

use of com.vaticle.typedb.core.common.exception.TypeDBException in project grakn by graknlabs.

the class RocksStorage method exception.

@Override
public TypeDBException exception(Exception exception) {
    TypeDBException e;
    if (exception instanceof TypeDBException)
        e = (TypeDBException) exception;
    else
        e = TypeDBException.of(exception);
    logger().debug(e.getMessage(), e);
    return e;
}
Also used : TypeDBException(com.vaticle.typedb.core.common.exception.TypeDBException)

Example 12 with TypeDBException

use of com.vaticle.typedb.core.common.exception.TypeDBException in project grakn by graknlabs.

the class ConjunctionResolver method initialiseDownstreamResolvers.

@Override
protected void initialiseDownstreamResolvers() {
    LOG.debug("{}: initialising downstream resolvers", name());
    Set<Concludable> concludables = concludablesTriggeringRules();
    Set<Retrievable> retrievables = Retrievable.extractFrom(conjunction(), concludables);
    resolvables.addAll(concludables);
    resolvables.addAll(retrievables);
    iterate(resolvables).forEachRemaining(resolvable -> {
        try {
            downstreamResolvers.put(resolvable, registry.registerResolvable(resolvable));
        } catch (TypeDBException e) {
            terminate(e);
        }
    });
    for (Negation negation : conjunction().negations()) {
        Negated negated = new Negated(negation);
        try {
            downstreamResolvers.put(negated, registry.negated(negated, conjunction()));
            negateds.add(negated);
        } catch (TypeDBException e) {
            terminate(e);
        }
    }
    if (!isTerminated())
        isInitialised = true;
}
Also used : Concludable(com.vaticle.typedb.core.logic.resolvable.Concludable) Retrievable(com.vaticle.typedb.core.logic.resolvable.Retrievable) Negation(com.vaticle.typedb.core.pattern.Negation) Negated(com.vaticle.typedb.core.logic.resolvable.Negated) TypeDBException(com.vaticle.typedb.core.common.exception.TypeDBException)

Example 13 with TypeDBException

use of com.vaticle.typedb.core.common.exception.TypeDBException in project grakn by graknlabs.

the class CoreConfigTest method config_file_wrong_path_type_throws.

@Test
public void config_file_wrong_path_type_throws() {
    Path configInvalidPathType = Util.getTypedbDir().resolve("server/test/config/config-wrong-path-type.yml");
    try {
        CoreConfigFactory.config(configInvalidPathType, new HashSet<>(), new CoreConfigParser());
        fail();
    } catch (TypeDBException e) {
        assert e.code().isPresent();
        assertEquals(CONFIG_UNEXPECTED_VALUE.code(), e.code().get());
        assertEquals(CONFIG_UNEXPECTED_VALUE.message("storage.data", "123456[int]", YAMLParser.Value.Primitive.PATH.help()), e.getMessage());
    }
}
Also used : Path(java.nio.file.Path) TypeDBException(com.vaticle.typedb.core.common.exception.TypeDBException) CoreConfigParser(com.vaticle.typedb.core.server.parameters.CoreConfigParser) Test(org.junit.Test)

Example 14 with TypeDBException

use of com.vaticle.typedb.core.common.exception.TypeDBException in project grakn by graknlabs.

the class CoreConfigTest method config_file_unrecognised_option.

@Test
public void config_file_unrecognised_option() {
    Path configUnrecognisedOption = Util.getTypedbDir().resolve("server/test/config/config-unrecognised-option.yml");
    try {
        CoreConfigFactory.config(configUnrecognisedOption, new HashSet<>(), new CoreConfigParser());
        fail();
    } catch (TypeDBException e) {
        assert e.code().isPresent();
        assertEquals(UNRECOGNISED_CONFIGURATION_OPTIONS.code(), e.code().get());
        assertEquals(UNRECOGNISED_CONFIGURATION_OPTIONS.message(list("log.custom-logger-invalid")), e.getMessage());
    }
}
Also used : Path(java.nio.file.Path) TypeDBException(com.vaticle.typedb.core.common.exception.TypeDBException) CoreConfigParser(com.vaticle.typedb.core.server.parameters.CoreConfigParser) Test(org.junit.Test)

Example 15 with TypeDBException

use of com.vaticle.typedb.core.common.exception.TypeDBException in project grakn by graknlabs.

the class CoreConfigTest method config_file_missing_debugger_throws.

@Test
public void config_file_missing_debugger_throws() {
    Path configMissingLogDebugger = Util.getTypedbDir().resolve("server/test/config/config-missing-debugger.yml");
    try {
        CoreConfigFactory.config(configMissingLogDebugger, new HashSet<>(), new CoreConfigParser());
        fail();
    } catch (TypeDBException e) {
        assert e.code().isPresent();
        assertEquals(MISSING_CONFIG_OPTION.code(), e.code().get());
        assertEquals(MISSING_CONFIG_OPTION.message("log.debugger"), e.getMessage());
    }
}
Also used : Path(java.nio.file.Path) TypeDBException(com.vaticle.typedb.core.common.exception.TypeDBException) CoreConfigParser(com.vaticle.typedb.core.server.parameters.CoreConfigParser) Test(org.junit.Test)

Aggregations

TypeDBException (com.vaticle.typedb.core.common.exception.TypeDBException)16 Test (org.junit.Test)11 Path (java.nio.file.Path)9 CoreConfigParser (com.vaticle.typedb.core.server.parameters.CoreConfigParser)7 CoreSession (com.vaticle.typedb.core.database.CoreSession)5 CoreTransaction (com.vaticle.typedb.core.database.CoreTransaction)5 ConceptMap (com.vaticle.typedb.core.concept.answer.ConceptMap)4 Actor (com.vaticle.typedb.core.concurrent.actor.Actor)4 Conjunction (com.vaticle.typedb.core.pattern.Conjunction)4 Disjunction (com.vaticle.typedb.core.pattern.Disjunction)4 Util.resolvedConjunction (com.vaticle.typedb.core.reasoner.resolution.Util.resolvedConjunction)4 Match (com.vaticle.typedb.core.reasoner.resolution.answer.AnswerState.Top.Match)4 Identifier (com.vaticle.typedb.core.traversal.common.Identifier)4 IOException (java.io.IOException)4 Collections.set (com.vaticle.typedb.common.collection.Collections.set)3 NamedThreadFactory (com.vaticle.typedb.common.concurrent.NamedThreadFactory)3 MB (com.vaticle.typedb.core.common.collection.Bytes.MB)3 Iterators.iterate (com.vaticle.typedb.core.common.iterator.Iterators.iterate)3 Arguments (com.vaticle.typedb.core.common.parameters.Arguments)3 Database (com.vaticle.typedb.core.common.parameters.Options.Database)3