当前位置: 首页>>代码示例>>Java>>正文


Java Exceptions.attachMessage方法代码示例

本文整理汇总了Java中org.openide.util.Exceptions.attachMessage方法的典型用法代码示例。如果您正苦于以下问题:Java Exceptions.attachMessage方法的具体用法?Java Exceptions.attachMessage怎么用?Java Exceptions.attachMessage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.openide.util.Exceptions的用法示例。


在下文中一共展示了Exceptions.attachMessage方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: actionPerformed

import org.openide.util.Exceptions; //导入方法依赖的package包/类
@Messages({"# {0} - module display name", "CTL_EditModuleDependencyTitle=Edit \"{0}\" Dependency"})
public @Override void actionPerformed(ActionEvent ev) {
    final EditTestDependencyPanel editTestPanel = new EditTestDependencyPanel(testDep);
    DialogDescriptor descriptor = new DialogDescriptor(editTestPanel,
            CTL_EditModuleDependencyTitle(testDep.getModule().getLocalizedName()));
    descriptor.setHelpCtx(new HelpCtx("org.netbeans.modules.apisupport.project.ui.customizer.EditTestDependencyPanel"));
    Dialog d = DialogDisplayer.getDefault().createDialog(descriptor);
    d.setVisible(true);
    if (descriptor.getValue().equals(DialogDescriptor.OK_OPTION)) {
        TestModuleDependency editedDep = editTestPanel.getEditedDependency();
        try {
            ProjectXMLManager pxm = new ProjectXMLManager(project);
            pxm.removeTestDependency(testType, testDep.getModule().getCodeNameBase());
            pxm.addTestDependency(testType, editedDep);
            ProjectManager.getDefault().saveProject(project);
            
            
        } catch (IOException e) {
            Exceptions.attachMessage(e, "Cannot store dependency: " + editedDep); // NOI18N
            Exceptions.printStackTrace(e);
        }
        
        
    }
    d.dispose();
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:27,代码来源:UnitTestLibrariesNode.java

示例2: getProjectRoots

import org.openide.util.Exceptions; //导入方法依赖的package包/类
@SuppressWarnings("DMI_COLLECTION_OF_URLS")
private static Set<URL> getProjectRoots(Project p) {
    Set<URL> projectRoots = new HashSet<URL>(); // roots
    Sources sources = ProjectUtils.getSources(p);
    SourceGroup[] sgs = sources.getSourceGroups(JavaProjectConstants.SOURCES_TYPE_JAVA);
    for (SourceGroup sg : sgs) {
        URL root;
        try {
            root = sg.getRootFolder().toURL();
            projectRoots.add(root);
        } catch (NullPointerException npe) {
            // http://www.netbeans.org/issues/show_bug.cgi?id=148076
            if (sg == null) {
                npe = Exceptions.attachMessage(npe, "Null source group returned from "+sources+" of class "+sources.getClass());
            } else if (sg.getRootFolder() == null) {
                npe = Exceptions.attachMessage(npe, "Null root folder returned from "+sg+" of class "+sg.getClass());
            }
            Exceptions.printStackTrace(npe);
        }
    }
    return projectRoots;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:23,代码来源:MainProjectManager.java

示例3: createXMLReader

import org.openide.util.Exceptions; //导入方法依赖的package包/类
/** Creates a SAX parser.
 *
 * <p>See {@link #parse} for hints on setting an entity resolver.
 *
 * @param validate if true, a validating parser is returned
 * @param namespaceAware if true, a namespace aware parser is returned
 *
 * @throws FactoryConfigurationError Application developers should never need to directly catch errors of this type.
 * @throws SAXException if a parser fulfilling given parameters can not be created
 *
 * @return XMLReader configured according to passed parameters
 */
public static synchronized XMLReader createXMLReader(boolean validate, boolean namespaceAware)
throws SAXException {
    SAXParserFactory factory = saxes[validate ? 0 : 1][namespaceAware ? 0 : 1];
    if (factory == null) {
        try {
            factory = SAXParserFactory.newInstance();
        } catch (FactoryConfigurationError err) {
            Exceptions.attachMessage(
                err, 
                "Info about thread context classloader: " + // NOI18N
                Thread.currentThread().getContextClassLoader()
            );
            throw err;
        }
        factory.setValidating(validate);
        factory.setNamespaceAware(namespaceAware);
        saxes[validate ? 0 : 1][namespaceAware ? 0 : 1] = factory;
    }

    try {
        return factory.newSAXParser().getXMLReader();
    } catch (ParserConfigurationException ex) {
        throw new SAXException("Cannot create parser satisfying configuration parameters", ex); //NOI18N                        
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:38,代码来源:XMLUtil.java

示例4: loadManifest

import org.openide.util.Exceptions; //导入方法依赖的package包/类
/** Open the JAR, load its manifest, and do related things. */
private void loadManifest() throws IOException {
    if (Util.err.isLoggable(Level.FINE)) {
        Util.err.fine("loading manifest of " + jar);
    }
    File jarBeingOpened = null; // for annotation purposes
    try {
        if (reloadable) {
            // Never try to cache reloadable JARs.
            jarBeingOpened = physicalJar; // might be null
            ensurePhysicalJar();
            jarBeingOpened = physicalJar; // might have changed
            JarFile jarFile = new JarFile(physicalJar, false);
            try {
                Manifest m = jarFile.getManifest();
                if (m == null) throw new IOException("No manifest found in " + physicalJar); // NOI18N
                manifest = m;
            } finally {
                jarFile.close();
            }
        } else {
            jarBeingOpened = jar;
            manifest = getManager().loadManifest(jar);
        }
    } catch (IOException e) {
        if (jarBeingOpened != null) {
            Exceptions.attachMessage(e,
                                     "While loading manifest from: " +
                                     jarBeingOpened); // NOI18N
        }
        throw e;
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:34,代码来源:StandardModule.java

示例5: parseBundle

import org.openide.util.Exceptions; //导入方法依赖的package包/类
/**
 * natural ordering of the items in the collection!
 */
public static Collection<Pair<String, String>> parseBundle(String name) {
    ClassLoader loader = getLoader();
    String sname = name.replace('.', '/');
    Properties p = new Properties();
    String res = sname + ".properties";

    // #49961: don't use getResourceAsStream; catch all errors opening it
    URL u = loader != null ? loader.getResource(res) : ClassLoader.getSystemResource(res);

    if (u != null) {
        //System.err.println("Loading " + res);
        try {
            try (InputStream is = u.openStream()) {
                Collection<Pair<String, String>> col = new ArrayList<>();
                load(is, col);
                return col;
            }
        } catch (IOException e) {
            Exceptions.attachMessage(e, "While loading: " + res); // NOI18N

            return null;
        }
    }

    return null;


}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:32,代码来源:PropertiesReader.java

示例6: getMethodDescriptor

import org.openide.util.Exceptions; //导入方法依赖的package包/类
/**
 * @param index Index to constant pool entries
 * @return method name
 * @throws IndexOutOfBoundsException when the constant pool size is smaller than index.
 */
public String getMethodDescriptor(int index) {
    try {
    EntryFieldMethodRef methodRef = (EntryFieldMethodRef) entries.get(index);
    return ((EntryUTF8) entries.get(((EntryNameType) entries.get(methodRef.nameAndTypeIndex)).getDescriptorIndex())).getUTF8();
    } catch (RuntimeException re) {
        throw Exceptions.attachMessage(re, description);
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:14,代码来源:ConstantPool.java

示例7: setAsText

import org.openide.util.Exceptions; //导入方法依赖的package包/类
public void setAsText(String txt) {
    String[] t = getTags();
    for (int i=0; i < t.length; i++) {
        if (txt.trim().equals(t[i])) {
            setValue(new Integer(i));
            return;
        }
    }
    IllegalArgumentException iae = new IllegalArgumentException(txt);
    Exceptions.attachMessage(iae, txt + " is not a valid value");
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:12,代码来源:EditableDisplayerTest.java

示例8: getPositionedSequence

import org.openide.util.Exceptions; //导入方法依赖的package包/类
public static <T extends TokenId>  TokenSequence<T> getPositionedSequence(BaseDocument doc, int offset, boolean lookBack, Language<T> language) {
    TokenSequence<T> ts = getTokenSequence(doc, offset, language);

    if (ts != null) {
        try {
            ts.move(offset);
        } catch (AssertionError e) {
            DataObject dobj = (DataObject)doc.getProperty(Document.StreamDescriptionProperty);

            if (dobj != null) {
                Exceptions.attachMessage(e, FileUtil.getFileDisplayName(dobj.getPrimaryFile()));
            }

            throw e;
        }

        if (!lookBack && !ts.moveNext()) {
            return null;
        } else if (lookBack && !ts.moveNext() && !ts.movePrevious()) {
            return null;
        }

        return ts;
    }

    return null;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:28,代码来源:LexUtilities.java

示例9: getType

import org.openide.util.Exceptions; //导入方法依赖的package包/类
public Class<?> getType( BFSBase foProvider) {
    try {
        switch(index) {
            case 0: return Byte.class;
            case 1: return Short.class;
            case 2: return Integer.class;
            case 3: return Long.class;
            case 4: return Float.class;
            case 5: return Double.class;
            case 6: return Boolean.class;
            case 7: return Character.class;
            case 8: return String.class;
            case 9: return URL.class;
            case 10: // methodvalue
                return methodValue(value, foProvider, null).getMethod().getReturnType();
            case 11: // newvalue
                return findClass (value);
            case 12: // serialvalue
                return null;
            case 13: // bundle value
                return String.class;
            default:
                throw new IllegalStateException("Bad index: " + index); // NOI18N
        }
    } catch (Exception exc) {
        Exceptions.attachMessage(exc, "value = " + value + " from " + foProvider.getPath()); //NOI18N
        LOG.log(notified.add(foProvider.getPath()) ? Level.INFO : Level.FINE, null, exc);
    }
    return null; // problem getting the value...
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:31,代码来源:BinaryFS.java

示例10: sendCaretToLine

import org.openide.util.Exceptions; //导入方法依赖的package包/类
public final boolean sendCaretToLine(int idx, boolean select) {
    int lastLine = getLineCount() - 1;
    if (idx > lastLine) {
        idx = lastLine;
    }
    inSendCaretToLine = true;
    try {
        getCaret().setVisible(true);
        getCaret().setSelectionVisible(true);
        Element el = textView.getDocument().getDefaultRootElement().getElement(idx);
        int position = el.getStartOffset();
        if (select) {
            getCaret().setDot(el.getEndOffset() - 1);
            getCaret().moveDot(position);
            textView.repaint();
        } else {
            getCaret().setDot(position);
        }

        if (!scrollToLine(idx + 3) && isScrollLocked()) {
            lineToScroll = idx + 3;
        }
    } catch (Error sie) {
        if (sie.getClass().getName().equals("javax.swing.text.StateInvariantError")) {
            Exceptions.attachMessage(sie, "sendCaretToLine("+idx+", "+select+"), caret = "+getCaret()+", highlighter = "+textView.getHighlighter()+", document length = "+textView.getDocument().getLength());
        }
        Exceptions.printStackTrace(sie);
    } finally {
        locked = false;
        inSendCaretToLine = false;
    }
    return true;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:34,代码来源:AbstractOutputPane.java

示例11: makeSymlink

import org.openide.util.Exceptions; //导入方法依赖的package包/类
private Process makeSymlink(String orig, File where) throws IOException {
    final String[] exec = { "/bin/ln", "-s", orig,  "lnk" };
    try {
        return Runtime.getRuntime().exec(exec, null, where);
    } catch (IOException ex) {
        Exceptions.attachMessage(ex, "cmd: " + Arrays.toString(exec) + " at: " + where);
        throw ex;
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:10,代码来源:CyclicSymlinkTest.java

示例12: executeImpl

import org.openide.util.Exceptions; //导入方法依赖的package包/类
@Override
@NonNull
protected boolean executeImpl() throws IOException {
    try {
        while(entries.hasMoreElements()) {
            final ZipEntry ze;
            try {
                ze = entries.nextElement();
            } catch (InternalError err) {
                LOGGER.log(
                        Level.INFO,
                        "Broken zip file: {0}, reason: {1}",    //NOI18N
                        new Object[] {
                            zipFile.getName(),
                            err.getMessage()
                        });
                return true;
            } catch (RuntimeException re) {
                if (re instanceof NoSuchElementException) {
                    //Valid for Enumeration.nextElement
                    throw (NoSuchElementException) re;
                }
                if (!brokenLogged) {
                    LOGGER.log(
                            Level.INFO,
                            "Broken zip file: {0}, reason: {1}",    //NOI18N
                            new Object[]{
                                zipFile.getName(),
                                re.getMessage()
                            });
                    brokenLogged = true;
                }
                continue;
            }
            if (!ze.isDirectory()  && accepts(ze.getName()))  {
                report (
                    ElementHandleAccessor.getInstance().create(ElementKind.OTHER, FileObjects.convertFolder2Package(FileObjects.stripExtension(ze.getName()))),
                    ze.getCrc());
                final InputStream in = new BufferedInputStream (zipFile.getInputStream( ze ));
                try {
                    analyse(in);
                } catch (InvalidClassFormatException | RuntimeException icf) {
                    LOGGER.log(
                            Level.WARNING,
                            "Invalid class file format: {0}!/{1}",      //NOI18N
                            new Object[]{
                                BaseUtilities.toURI(new File(zipFile.getName())),
                                ze.getName()});
                    LOGGER.log(
                            Level.INFO,
                            "Class File Exception Details",             //NOI18N
                            icf);
                } catch (IOException x) {
                    Exceptions.attachMessage(x, "While scanning: " + ze.getName());    //NOI18N
                    throw x;
                }
                finally {
                    in.close();
                }
                if (lmListener.isLowMemory()) {
                    flush();
                }
            }
            if (isCancelled()) {
                return false;
            }
        }
        return true;
    } finally {
        zipFile.close();
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:73,代码来源:BinaryAnalyser.java

示例13: getMessage

import org.openide.util.Exceptions; //导入方法依赖的package包/类
@Override
public synchronized String getMessage() {
    if (message == null) {
        try {
            Method getMessageMethod = ClassTypeWrapper.concreteMethodByName((ClassType) ValueWrapper.type(exeption),
                        "getMessage", "()Ljava/lang/String;");  // NOI18N
            if (getMessageMethod == null) {
                if (invocationMessage != null) {
                    message = "";
                } else {
                    message = "Unknown exception message";
                }
            } else {
                try {
                    StringReference sr = (StringReference) debugger.invokeMethod (
                            preferredThread,
                            exeption,
                            getMessageMethod,
                            new Value [0],
                            this
                        );
                    message = sr != null ? StringReferenceWrapper.value(sr) : ""; // NOI18N
                } catch (InvalidExpressionException ex) {
                    if (ex.getTargetException() == this) {
                        String msg = getMessageFromField();
                        if (msg == null) {
                            if (invocationMessage != null) {
                                message = "";
                            } else {
                                message = "Unknown exception message";
                            }
                        }
                    } else {
                        return ex.getMessage();
                    }
                } catch (VMMismatchException vmMismatchEx) {
                    VirtualMachine ptvm = ((preferredThread != null) ? preferredThread.getThreadReference().virtualMachine() : null);
                    VirtualMachine ctvm = null;
                    JPDAThread currentThread = debugger.getCurrentThread();
                    if (currentThread != null) {
                        ctvm = ((JPDAThreadImpl) currentThread).getThreadReference().virtualMachine();
                    }
                    throw Exceptions.attachMessage(vmMismatchEx, "DBG VM = "+printVM(debugger.getVirtualMachine())+
                                                               ", preferredThread VM = "+printVM(ptvm)+
                                                               ", currentThread VM = "+printVM(ctvm)+
                                                               ", exeption VM = "+printVM(exeption.virtualMachine()));
                }
            }
        } catch (InternalExceptionWrapper iex) {
            return iex.getMessage();
        } catch (VMDisconnectedExceptionWrapper vdex) {
            return vdex.getMessage();
        } catch (ObjectCollectedExceptionWrapper ocex) {
            Exceptions.printStackTrace(ocex);
            return ocex.getMessage();
        } catch (ClassNotPreparedExceptionWrapper cnpex) {
            return cnpex.getMessage();
        }
    }
    if (invocationMessage != null) {
        return invocationMessage + ": " + message;
    } else {
        return message;
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:66,代码来源:InvocationExceptionTranslated.java

示例14: testAttachMessage

import org.openide.util.Exceptions; //导入方法依赖的package包/类
public void testAttachMessage() {
    Exception e = new Exception("Help");
    String msg = "me please";
    
    Exception result = Exceptions.attachMessage(e, msg);

    assertSame(result, e);

    StringWriter w = new StringWriter();
    result.printStackTrace(new PrintWriter(w));

    String m = w.toString();

    if (m.indexOf(msg) == -1) {
        fail(msg + " shall be part of output:\n" + m);
    }

    assertCleanStackTrace(e);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:20,代码来源:ExceptionsTest.java

示例15: configureFrom

import org.openide.util.Exceptions; //导入方法依赖的package包/类
/** Utility method which performs configuration which is common to all of the renderer
 * implementations - sets the icon and focus properties on the renderer
 * from the VisualizerNode.
 *
 */
private int configureFrom(
    HtmlRenderer.Renderer ren, Container target, boolean useOpenedIcon, boolean sel, VisualizerNode vis
) {
    if (!isShowIcons()) {
        ren.setIcon(null);
        ren.setIndent(labelGap);
        return 24;
    }
    
    Icon icon = vis.getIcon(useOpenedIcon, bigIcons);

    if (icon.getIconWidth() > 0) {
        //Max annotated icon width is 24, so to have all the text and all
        //the icons come out aligned, set the icon text gap to the difference
        //plus a two pixel margin
        ren.setIconTextGap(24 - icon.getIconWidth());
    } else {
        //If the icon width is 0, fill the space and add in
        //the extra two pixels so the node names are aligned (btw, this
        //does seem to waste a frightful amount of horizontal space in
        //a tree that can use all it can get)
        ren.setIndent(26);
    }

    try {
        ren.setIcon(icon);
    } catch (NullPointerException ex) {
        Exceptions.attachMessage(ex, "icon: " + icon); // NOI18N
        Exceptions.attachMessage(ex, "vis: " + vis); // NOI18N
        Exceptions.attachMessage(ex, "ren: " + ren); // NOI18N
        throw ex;
    }

    if (target instanceof TreeTable.TreeTableCellRenderer) {
        TreeTable.TreeTableCellRenderer ttRen = (TreeTable.TreeTableCellRenderer) target;
        TreeTable tt = ttRen.getTreeTable();
        ren.setParentFocused(ttRen.treeTableHasFocus() || tt.isEditing());
    }

    return (icon.getIconWidth() == 0) ? 24 : icon.getIconWidth();
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:47,代码来源:NodeRenderer.java


注:本文中的org.openide.util.Exceptions.attachMessage方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。